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

Posted by solefald on Stack Overflow See other posts from Stack Overflow or by solefald
Published on 2010-04-16T16:23:21Z Indexed on 2010/04/16 16:33 UTC
Read the original article Hit count: 314

Hello,

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'
                    });
               }



   );

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about jquery-ui