Reputation: 2367
I have this code :
$.ajax({
type: "POST",
url: "tosql.php",
data: {
content, content
}
});
I was wondering how I could get a callback from tosql.php (the result) and add that html to div class = "content"
Upvotes: 1
Views: 69
Reputation: 342765
Do that within the success
callback:
$.ajax({
type: "POST",
url: "tosql.php",
data: {
content: content
},
success: function(html) {
// you said 'add' so I'm assuming '.append'
// if you meant fill/replace then use `.html(html);`
$("div.content").append(html);
}
});
Also (if it's not a typo on your part), object property names and values are separated by the colon:
data: {
content: content
},
and not the comma:
data: {
content, content
},
Upvotes: 3
Reputation: 32127
$.ajax({
type: "POST",
url: "tosql.php",
data: {
content: content
},
success:function(data)
{
jQuery('#target').html(data);
}
});
Upvotes: 0
Reputation: 151
ok maybe this code is true and solve your problem.. data : mydata *success: resultdt*
var mydata = $(".form").serialize();
$.ajax({
type: "POST",
url: "tosql.php",
data: mydata,
sucess: resultdt
});
function resultdt(data,status){
data=$.trim(data);
$(".c").html(data);
}
Upvotes: 0