jQuery Ajax error handling, show custom exception messages

前端 未结 21 3260
滥情空心
滥情空心 2020-11-22 01:50

Is there some way I can show custom exception messages as an alert in my jQuery AJAX error message?

For example, if I want to throw an exception on the server side v

21条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 02:18

    I found this to be nice because I could parse out the message I was sending from the server and display a friendly message to the user without the stacktrace...

    error: function (response) {
          var r = jQuery.parseJSON(response.responseText);
          alert("Message: " + r.Message);
          alert("StackTrace: " + r.StackTrace);
          alert("ExceptionType: " + r.ExceptionType);
    }
    

提交回复
热议问题