Intercept ajax requests with jquery to display BlockUI

时光总嘲笑我的痴心妄想 提交于 2019-12-07 19:34:17

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/2592015/intercept-ajax-requests-with-jquery-to-display-blockui

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!