Search code examples
jquery-uijqueryjeditable

jQuery.post() issues with passing data to jQuery UI


I am trying to get jQuery.post() to run my php script and then open a jQuery UI dialog with the data that php script returns. Its supposed to come back as a form with a table and a textarea in it. It works great with alert(data); and i get a pop-up with all my data.

The problem starts if i turn off alert(). Now it opens 2 dialogs. One containing only the table, without textarea, and the second one absolutely empty.

What am i doing wrong here? How come all my data shows up in the alert(), but not in dialog? What do i need to do to fix it?

Oh, and do i need to also include $.ajax() before the $.post()?

Thank you.

 $.post("/path/to/script.php", 
               { id: this.id, value: value },
               function(data){

                     // THIS WORKS
                     //alert(data);

                     // THIS DOES NOT WORK
                     $(data).dialog({ 
                             autoOpen: true,
                             width: 400,
                             modal: true,
                             position: 'center',
                             resizable: false,
                             draggable: true,
                             title: 'Pending Changes'
                    });
               }



   );

Solution

  • Ah! This was not a problem with the JS, but my php file.

    The textarea was sitting outside of <div>blah blah</div>.

    Problem solved.