$(function() {
    $.ajaxSetup({
        error: function(jqXHR, exception) {
            if (jqXHR.status === 0) {
                alert('Not connect.\n Verify Network.');
            } else if (jqXHR.status == 404) {
                alert('Requested page not found. [404]');
            } else if (jqXHR.status == 500) {
                alert('Internal Server Error [500].');
            } else if (exception === 'parsererror') {
                alert('Requested JSON parse failed.');
            } else if (exception === 'timeout') {
                alert('Time out error.');
            } else if (exception === 'abort') {
                alert('Ajax request aborted.');
            } else {
                alert('Uncaught Error.\n' + jqXHR.responseText);
            }
        }
    });
});

参考:

http://www.unseenrevolution.com/jquery-ajax-error-handling-function/

http://stackoverflow.com/questions/377644/jquery-ajax-error-handling-show-custom-exception-messages

相关文章:

  • 2021-11-05
  • 2021-11-05
  • 2021-09-27
  • 2021-08-23
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
猜你喜欢
  • 2022-12-23
  • 2021-10-11
  • 2021-09-11
  • 2022-12-23
  • 2021-10-20
  • 2021-09-16
  • 2021-09-09
相关资源
相似解决方案