Reputation: 105
I am having trouble including a php page in a div after an Ajax call.
I want to include page.php in the div with id=content on an Ajax success function
<div id="content"></div>
function load(a, b) {
$.ajax({
url: "page.php",
type: "POST",
data: {
"a": a,
"b": b
},
success: function(data) {
console.log(data);
$("#content").load("page.php"); //What am I doing wrong here?
return false;
},
error: function(jqXHR, error_string, error) {
console.log(error);
}
});
}
Upvotes: 0
Views: 77
Reputation: 2384
When you call page.php with $.ajax, the variable data
contains the page contents.
So you just have to append the page contents to your div.
$('#content').append(data);
Upvotes: 1