在Ajax中更新对象的最佳时间是什么时候?

在Ajax中更新对象的最佳时间是什么时候?,ajax,Ajax,我用ajax和php发送和接收帖子,现在什么时候更新我对html的回复最好,在发送帖子之后还是之前?这取决于时间 我所使用/看到的最常见的方法是在收到通过AJAX执行的PHP脚本的响应后更新HTML jQuery示例: $.post('script.php', {name_1: value_1, name_2: value_2}, function(data){ /* this is the function that is fired upon a successful AJAX

我用ajax和php发送和接收帖子,现在什么时候更新我对html的回复最好,在发送帖子之后还是之前?

这取决于时间

我所使用/看到的最常见的方法是在收到通过AJAX执行的PHP脚本的响应后更新HTML

jQuery示例:

$.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
});