如何让jQuery的AJAX状态code状态、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: "keyw...

我想知道,我们如何才能让阿贾克斯状态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()

阅读全文

相关推荐

最新文章