Because the project is a lot of practical .PosTSquareMethod,andtheSquareMethodTacitrecognizeNothePleaseAskof thedifferentoftenintoLinePlaceManagement,afterperiodandto bePlaceManagementtheAskQuestions. beforeperiodof theSolutiondecisionSquareCaseis awill bemakewith The. Post requests are transformed into $.ajax requests, but due to the fact that the implementation of the two methods (required parameters) is quite different, the changes are cumbersome!
During an attempt to use the definition "AJAX request error occurs when executing the function (document). Ajaxerror ())"
The way to solve the problem, but the scope of the impact is too large, the long polling error is also captured, causing the page to open the dialog box that pops up the system exception.
So here's the technique of extending the jquery approach to solve the problem:
/* Extended Jquery.post method * is used to support error handling, the original use of $.post only need to change to $.postex, do not need to make other changes; * If you need to handle exceptions separately, set the fourth parameter to an exception handler; */JQuery. Extend({ postex:function (Requesturl, SendData, Successcallback, Errorcallback) {if (type of Errorcallback = = = ' undefined ') {errorcallback = Ajaxerrorex; }$. Ajax({ URL: requesturl, Data:senddata, type: ' post ', Cache:false, DataType: ' json ', timeout: 30000, SUCCESS:SUCC Esscallback, Error:errorcallback }); }});
Unified Exception Handling: Original use .PosTof thetoSquareonlyneedto beChangeto be . Postex, no other changes are required;
Handling Exceptions individually: If you need to handle exceptions separately, set the fourth parameter to the exception handler;
The method of extending jquery uniformly handles exception error messages generated during AJAX calls