如何让jQuery的AJAX状态code [英] how to get jquery ajax status code

查看:129
本文介绍了如何让jQuery的AJAX状态code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,我们如何才能让阿贾克斯状态code jQuery中。 我有这样的AJAX块:

I want to know that how can we get ajax status code in jquery. I have this ajax block:

$.ajax{
    type: "GET",
    url: "keyword_mapping.html",
    data:"ajax=yes&sf="+status_flag,

    success: callback.success,
    complete: rollup_filters(),
    failure: function(){
        alert("Failure");
    }
    }

现在在上面code,在失败的情况下,如何才能得到阿贾克斯状态code和这种地位code ??

Now in above code, in case of failure, how can i get ajax status code and some description of that status code ??

推荐答案

您要使用的 错误 选项捕捉到了这个。例如:

You want to use the error option to capture this. For example:

error: function (jqXHR, textStatus, errorThrown)
    // Your handler here...
}

您可以用 jqXHR 对象检索有关失败的信息。

You can then use the jqXHR object to retrieve information about the failure.

从文档

对于XMLHtt prequest向后兼容,一个jqXHR对象将公开下列属性和方法:

For backward compatibility with XMLHttpRequest, a jqXHR object will expose the following properties and methods:

      
  • 的readyState
  •   
  • 状态
  •   
  • 状态文本
  •   
  • responseXML的和/或responseText的时候,底层请求报以xml和/或文字,分别为
  •   
  • 在setRequestHeader(名称,值),它通过用新的代替旧的价值,而不是串联的新值旧
  • 偏离标准   
  • getAllResponseHeaders()
  •   
  • getResponseHeader()
  •   
  • 中止()
  •   
  • readyState
  • status
  • statusText
  • responseXML and/or responseText when the underlying request responded with xml and/or text, respectively
  • setRequestHeader(name, value) which departs from the standard by replacing the old value with the new one rather than concatenating the new value to the old one
  • getAllResponseHeaders()
  • getResponseHeader()
  • abort()

这篇关于如何让jQuery的AJAX状态code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆