2011-10-12 44 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 

});