How to Implement jQuery Ajax Error handling in ASP.NET MVC Project
Updated: October 3, 2016 | Technology: Asp.Net, Asp.Net MVC
This article is for solving a problem of jquery ajax error facing in Asp.Net MVC projects.
The problem with Ajax Errors:
During in asp.net programming, We have plenty of Ajax methods in our asp.net MVC project. The problem is that some methods were broken. so that, we having not get exactly in which methods the issue was arises. this is actually because of jquery ajax error.
The solution for Ajax Errors:
We can solve issues two ways:
- Handling error for individual methods.
- Handling error using a single(Global) method.
If we handle error for individual methods. it will take lots of efforts for us to put error handling code in individual methods. Another approach for handle code using global method.
Examples:
- Handling error using a single(Global) method:
Parameters:
settings: settings object that was used in the creation of the request information such as settings.url.
thrown Error: receives the textual portion of the HTTP status, such as “Not Found” or “Internal Server Error.”
- Handling error for individual methods:
Conclusion:
We can handle ajax error two ways one for an individual method. one for using a single global method so it is good practice if we handle ajax.error method globally rather than doing code for the individual method. There are many global Ajax methods such as follow:
- .ajaxComplete()
- .ajaxError()
- .ajaxSend()
- .ajaxStart()
- .ajaxStop()
- .ajaxSuccess()
Reference Links:
Please check below link For reference, see how it is written:
https://api.jquery.com/ajaxError/
Kindly visit our latest articles related to Asp.net MVC using c# programming and much more.
Thanks…!!