Search code examples
jqueryjquery-ui-dialogjquery-post

Send ajax request to a file inside Jquery Dialog


I am trying to send an ajax request to a page that is loaded inside the Jquery Dialog box. This is my dialog box code:

$('#dialog').dialog({
        modal: false,
        open: function ()
        {
            $(this).load('window.php');
        },         
        height: 240,
        width: 400,
        title: 'Ajax Page'
    });

Now i have a link in my page, that sends ajax request to the "window.php" page, on click:

 $.post("window.php", { username: username }

And in the loaded page (window.php), i put the code to print the post parameters...

<?php
echo 'Hello world';
var_dump($_POST);
if(isset($_POST['username']))
{
echo ':: '.$_POST['username'];
}
?>

But to my surprise, i am not getting any request parameters printed in the loaded page of dialog box. I am just getting Hello world. What could be the issue?


Solution

  •  $.post('ajax/test.html', function(data) {
          $('#dialog').html(data);
        });