简体   繁体   中英

ASP.NET MVC 4 Action on AJAX Request

Is there a way to call a javascript function every time an AJAX request is sent, and then another when the call is finished? I know you can do it individually for each form with the OnBegin and OnComplete functions, but I want a universal one.

Specifically, I would like the wait cursor to show every time it sends an ajax call, and then go back to the default cursor when done.

With webforms you could do

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);

but I need something for MVC 4.

Any suggestions on how to accomplish this task would be appreciated, or alternatives if it's just a bad idea.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM