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
});
精彩评论