开发者

getting a response from $.post

开发者 https://www.devze.com 2023-04-12 04:26 出处:网络
I\'m calling an ajax page using $.post. $.post(\"ajaxpage.php\", $(\"#theform\").serialize()); How can I echo the response that the page returned? I tried saving to a var, but it\'s not giving me

I'm calling an ajax page using $.post.

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

How can I echo the response that the page returned? I tried saving to a var, but it's not giving me the response.

var resp = $.post("ajaxpage.php", $("#theform").se开发者_C百科rialize());
console.log(resp);


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


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

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

});
0

精彩评论

暂无评论...
验证码 换一张
取 消