How do you handle errors from AJAX calls?

前端 未结 5 1475
刺人心
刺人心 2020-12-23 14:59

Let\'s say I have the following jQuery AJAX call:

$.ajax({
   type: \"POST\",
   url: \"MyUrl\",
   data: \"val1=test\",
   success: function(result){
               


        
5条回答
  •  执念已碎
    2020-12-23 15:07

    Doesn't the jQuery ajax function accept one more parameter at the end, a callback for failed calls? If so, just add a fail:function(...){..} after the success callback.

提交回复
热议问题