开发者

Intercept ajax requests with jquery to display BlockUI

开发者 https://www.devze.com 2022-12-26 03:36 出处:网络
i\'m trying to intercept ajax requests with jquery, to display a waiting message like with using plugin BlockUI, but how can i intercept requests sended by the UpdatePanel provided from asp.net framew

i'm trying to intercept ajax requests with jquery, to display a waiting message like with using plugin BlockUI, but how can i intercept requests sended by the UpdatePanel provided from asp.net framework, is some wa开发者_运维知识库y to take the trigger?

Thanks


You can use the beginRequest and endRequest client side events of the PageRequestManager to display a "please wait" UI.

Sys.WebForms.PageRequestManager.instance.add_beginRequest(beginRequestHandler)

Sys.WebForms.PageRequestManager.instance.add_endRequest(endRequestHandler)

See here for more information. There are examples for each event.


I don't really know what an UpdatePanel is, but generally you could use the ajax global events for that, e.g.:

$(document).bind("ajaxStart", function() {
    $.blockUI();
}).bind("ajaxStop", function() {
    $.unblockUI();
});

If you have ajax calls outside of the UpdatePanel that you do not want to block the interface, you would need to set the ajax option:

global: false,

to ensure that they are excluded.

0

精彩评论

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

关注公众号