How do I detect the start of a ajax call?
In JQtouch, any link is automatically convert into ajax call. I want to detect the moment the ajax call was send. This is so that i could insert a loading screen to let users know t开发者_开发技巧hat the system is processing the submission.
I search through jqTouch API and apparently they only have callback events for page animation. Am i missing out on anything?
You can use the core jQuery global AJAX functions, for example $.ajaxStart()
for the start of a batch of requests, or $.ajaxSend()
to detect the beginning of each request. Something like this:
$(document).ajaxSend(function() {
alert("Request sending...");
});
Ready up on jQuery's Ajax Events: http://docs.jquery.com/Ajax_Events .
You may bind these to elements as follows:
$("...").bind("ajaxSend",myFunction) ;
every element specified this way will then react to a Ajax call being made with the specified callback function.
精彩评论