gra*_*aup 12 javascript firefox http xmlhttprequest
我正在使用Django构建一个Web应用程序.我通过Ajax(jQuery v1.8.3)在Javascript中有一堆API调用.
它们中的大多数都可以工作,但是特定的一个会导致状态为0的返回对象,并且此消息为statusText:
[Exception... "'JavaScript component does not have a method named: "available"' when calling method: [nsIInputStream::available]" nsresult: "0x80570030 (NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED)" location: "JS frame :: http://127.0.0.1:8000/media/js/jquery.js :: .send :: line 8434" data: no]
jQuery中的对应行是 xhr.send( ( s.hasContent && s.data ) || null );
但是,这只发生在Firefox中.Chrome工作正常.同样,其他请求也可以.唯一让这个与众不同的是DELETE http方法.
请求如下(Chrome中显示的HTTP网络数据 - Firebug在Firefox中没有显示任何内容):
Request URL: http://127.0.0.1:8000/api/reservation/13/
Request Method: DELETE
Status Code: 400 BAD REQUEST (This is expected)
Request Headers
Accept: application/json, text/javascript, */*; q=0.01
Content-Length: 15
Content-Type: application/json
Origin: http://127.0.0.1:8000
Referer: http://127.0.0.1:8000/reservation/
X-Requested-With: XMLHttpRequest
Request Payload
[object Object]
Response Headers
Cache-Control: no-cache
Content-Type: text/html; charset=utf-8
Date: Tue, 02 Apr 2013 19:18:35 GMT
Server: WSGIServer/0.1 Python/2.7.2
Run Code Online (Sandbox Code Playgroud)
在服务器上,我没有收到任何请求.
JS代码(在断点处直接从Firebug Watch获取):
options = {
contentType: "application/json",
data: Object {},
dataType: "json",
processData: false,
type: "DELETE",
url: "/api/reservation/13/",
error: function(),
success: function()
};
$.ajax(options);
Run Code Online (Sandbox Code Playgroud)
我也尝试禁用FF中的所有扩展.我跑v20.0.
gra*_*aup 27
问题是Firefox与jQuery/XMLHttpRequest的组合以及通过HTTP DELETE 发送对象.一旦JSON通过JSON.stringify()一切工作确定对象.
仍然是Firefox抛出的奇怪例外.
感谢freddyb的想法.
问题在于函数processData内部调用的属性$.ajax.当此属性以"false"(不知道原因)提供时,Firefox不喜欢它,因此,浏览器不会消化JSON请求/响应包.Chrome和Safari工作得很好.
| 归档时间: |
|
| 查看次数: |
7438 次 |
| 最近记录: |