2011-10-12 63 views
1

我打电话给一个ajax页面使用$.post

$.post("ajaxpage.php", $("#theform").serialize()); 

我该如何回应页面返回的响应?我试着保存到一个变种,但它没有给我回应。

var resp = $.post("ajaxpage.php", $("#theform").serialize()); 
console.log(resp); 
+0

后异步调用。如果每次询问这个问题时我都有镍,我就可以购买整个[SE]网络。 – zzzzBov

+2

你甚至读过它的文档吗? –

+0

@zzzzbov而且,你几天前为同一张海报发布了一个实用程序。 –

回答

4
$.post("ajaxpage.php", $("#theform").serialize(), function(data, status, xhr) { 
    console.log(data); 
}); 
3

http://api.jquery.com/jQuery.post/

$.post("ajaxpage.php", $("#theform").serialize(),function(data){ 
    $('#yourDivId').html(data);//data is what you recived from the server 

});