问题描述
我得到状态代码0 ......但它是代码403.
有人可以告诉我这是什么问题吗?
i get the statuscode 0 ... but it is the code 403.Can someone tell me what the problem is?
If you need the browser to access data like this asynchronously, you'll need to write a wrapper on your server to fetch the information from the remote server and feed it to the browser. There is a workaround (it's called JSONP – JSON with Padding)
编辑:每,可以通过更改代码将 dataType
设置为 jsonp $ c $来执行JSONP请求c>。
Per gradbot's answer, it is possible to do a JSONP request by changing your code to set dataType
to jsonp
.
但是,您现在无法使用 xhr.status
。这是因为JSONP不使用XHR对象,因此没有可供检查的状态。
However, you won't now be able to use xhr.status
. This is because JSONP does not use the XHR object, so there is no status available to check.
的工作示例。请注意,结果对象将传递给处理程序,而不是jqXHR对象。
Here's a working example using the feed gradbot suggested. Note that the result object is passed to the handler, rather than the jqXHR object.
这篇关于jqXHR - http-status-code-403(但状态码为0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!