0
即时通讯发送和接收与ajax和PHP的帖子,现在什么时候会是最好的时间来更新我的回应我的HTML,发送后或之前?什么时候是更新Ajax中的对象的最佳时机?
即时通讯发送和接收与ajax和PHP的帖子,现在什么时候会是最好的时间来更新我的回应我的HTML,发送后或之前?什么时候是更新Ajax中的对象的最佳时机?
这取决于。
我使用/看到的最常见方法是在您通过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
});