Firefox异常“JavaScript组件没有一个名为”available“的方法 [英] Firefox exception 'JavaScript component does not have a method named: "available"'
问题描述
大部分工作,但是特定的一个返回对象的状态为0和这个消息作为statusText:
[Exception ...JavaScript组件在调用时没有一个名为available的方法方法:[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中不显示任何内容):
请求网址:http://127.0.0.1:8000/api/reservation/13/
$在服务器上,我没有收到任何请求。
请求方法:DELETE
状态码:400 BAD REQUEST(这是预期的)
请求标题
接受:application / json,text / javascript,* / *; q = 0.01
Content-Length:15
Content-Type:application / json
原点:http://127.0.0.1:8000
Referer:http://127.0。请求有效载荷
[对象对象]
响应头
高速缓存-Control:no-cache
Content-Type:text / html; charset = utf-8
日期:2013年4月2日星期二19:18:35 GMT
服务器:WSGIServer / 0.1 Python / 2.7.2
JS代码(直接从Firebug Watch at breakpoint):
options = {
contentType:application / json,
data :Object {},
dataType:json,
processData:false,
类型:DELETE,
url:/ api / reservation / 13 /,
error:function(),
success:function()
};
$ .ajax(options);
我也尝试禁用FF中的所有扩展。我运行v20.0。
解决方案问题是Firefox与jQuery / XMLHttpRequest的结合,发送对象通过HTTP DELETE。一旦JSON对象通过
JSON.stringify()
一切正常。
不过,Firefox的一个奇怪的例外抛出。
感谢freddyb这个想法。
I'm building a web app with Django. I have a bunch of API calls in Javascript via Ajax (jQuery v1.8.3).
Most of them work, but a particular one results in a return object with status 0 and this message as the 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]
The corresponding line in jQuery is
xhr.send( ( s.hasContent && s.data ) || null );
However, this occurs only in Firefox. Chrome works fine. Again, other requests do work. The only thing which sets this one apart is the DELETE http method.
The request is as follow (HTTP network data shown in Chrome – Firebug doesn't show anything in 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
On the server, I don't receive any request.
The JS code is (taken directly from Firebug Watch at breakpoint):
options = { contentType: "application/json", data: Object {}, dataType: "json", processData: false, type: "DELETE", url: "/api/reservation/13/", error: function(), success: function() }; $.ajax(options);
I also did try to disable all extensions in FF. I run v20.0.
解决方案The problem was a combination of Firefox with jQuery/XMLHttpRequest and sending an object via HTTP DELETE. Once JSON'ifying the object via
JSON.stringify()
everything worked.Still, a strange exception for Firefox to throw.
Thanks to freddyb for that idea.
这篇关于Firefox异常“JavaScript组件没有一个名为”available“的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!