How do you handle errors from AJAX calls?

前端 未结 5 1485
刺人心
刺人心 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:27

    Return an error code on the server side using the HTTP error the best equates to what the error is. Then use the error callback. This will also allow you to show errors given by your webserver.

提交回复
热议问题