当开机自检失败时,调用哪种类型的 AJAX 事件

What kind of AJAX event do you call when a POST fails?

本文关键字:类型 种类 AJAX 事件 调用 开机自检 失败      更新时间:2023-09-26

当帖子失败时,你会调用哪个jQuery AJAX事件?例如,如果站点记录此消息:

POST http://s-t-h-c.appspot.com/dispatch 500 (Internal Server Error)

哪个 AJAX 事件处理程序处理它?例如,如果请求成功,我们可以使用:

$.ajax({
success: function() {
}
});

我已经尝试过error:ajaxError:,但他们似乎无法抓住这个问题。

任何帮助将不胜感激!谢谢!

~地毯嘶嘶声

当你添加success:时,Ajax中也有error:

作为示例代码,我将在这里发布一个

  $.ajax({
    type: 'GET',
    dataType: 'json',
    url: url,
    timeout: 5000,
    success: function(data, textStatus ){
       alert('request successful');
    },
    error: function(xhr, textStatus, errorThrown){
       alert('request failed');
    }
  });

干杯!

$.ajax(
        {
        type: "GET",
        cache: false,
        url: url,
        dataType: "xml",
        contentType: "text/html",
        success: processData,
        error: errorAlert
        }); //end of AJax

//Package the code that handles
        //error message in case the request
        //is not successful:
        function errorAlert(e, jqxhr)
        {
        alert("Your request was not successful: " + jqxhr);
        }