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