how do I append a PHP page to a div? I know the following will work:
$("#mycontainer").append( $('<div />').load('/myscript.php') );
...but what if I don't want it wrapped in a DIV?
Important to note that I want to APPEND and note replace the contents of "#mycontainer".
Could use $.ajax()
or $.get()
instead:
$.get('/myscript.php', function(result) {
$("#mycontainer").append(result);
});
One way
.unwrap() the .contents() of div
before u append it
$("#mycontainer").append(function () {
return $('<div />').load('/myscript.php').contents().unwrap('div');
});
To load something into an existing container (and replace its content), do this:
$("#mycontainer").load('/myscript.php');
To append (and keep current content), you need $.ajax() or $.get()