开发者

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

开发者 https://www.devze.com 2023-02-14 19:27 出处:网络
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.

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

精彩评论

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