Intercept ajax requests with jquery to display Blo

2019-05-23 00:22发布

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 way to take the trigger?

Thanks

2条回答
Animai°情兽
2楼-- · 2019-05-23 00:51

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.

查看更多
劫难
3楼-- · 2019-05-23 00:58

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.

查看更多
登录 后发表回答