简体   繁体   English

ASP.NET MVC 4对AJAX请求的操作

[英]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? 有没有办法在每次发送AJAX请求时调用javascript函数,然后在调用结束时调用另一个函数? I know you can do it individually for each form with the OnBegin and OnComplete functions, but I want a universal one. 我知道你可以使用OnBegin和OnComplete函数为每个表单单独完成它,但我想要一个通用的表单。

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. 具体来说,我希望每次发送ajax调用时都会显示等待光标,然后在完成后返回默认光标。

With webforms you could do 使用webforms,你可以做到

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

but I need something for MVC 4. 但我需要一些MVC 4。

Any suggestions on how to accomplish this task would be appreciated, or alternatives if it's just a bad idea. 任何关于如何完成这项任务的建议都会受到赞赏,或者如果它只是一个坏主意的替代品。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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