开发者

How do I detect the start of a ajax call?

开发者 https://www.devze.com 2023-01-15 15:36 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消