开发者

When would be best time to update an object in Ajax?

Im sending and receiving posts with ajax and php, now when would 开发者_StackOverflow社区be the best time to update my response to my html, after send post or before?


It depends.

The most common approach I have used/seen is to update your HTML after you receive a response from the PHP script you are executing via AJAX.

jQuery example:

$.post('script.php', {name_1: value_1, name_2: value_2}, function(data){
  /*
    this is the function that is fired upon a successful AJAX execution
    the data variable contains the data script.php outputs
  */
  //update html here
});
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜