I have a function which has a jQuery.post being done, with POST parameters passed to it.
function executeFunction(){
jQuery.post("../somefile.php", {executeFunction:true});
}
If I’m not wrong, this is async behavior.
Elsewhere in the code, I have:
executeFunction(function(){
jQuery('#box').reload();
});
After the async behavior is done, I need to take the action of jQuery(‘#box’).reload();
How do I put a check to see if the async behavior has been accomplished?
This third argument to
$.post()is the callback function, it runs when your data comes back, like this:In the above example the pair
executeFunction=trueis being passed to the server, if that wasn’t your intent and you just want to post no data, it looks like this:Also, that callback receives a few parameters if you need to use them, the data (server response), the status, and the XmlHttpRequest, so you can do this for example: