Prototype 1.5.0 and json.js
Exception ``[object Object]'' thrown from function anonymous(value=string:"get") in <http://ascend.local/javascript/prototype.1.5.0.js> line 407.
Exception ``[object Object]'' thrown from function anonymous(value=string:"get") in <http://ascend.local/javascript/prototype.1.5.0.js> line 328.
Exception ``[object Object]'' thrown from function anonymous() in <http://ascend.local/javascript/prototype.1.5.0.js> line 330.
Exception ``[object Object]'' thrown from function anonymous(iterator=function:anonymous) in <http://ascend.local/javascript/prototype.1.5.0.js> line 541.
Exception ``[object Object]'' thrown from function anonymous(iterator=function:anonymous) in <http://ascend.local/javascript/prototype.1.5.0.js> line 326.
Exception ``[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.setRequestHeader]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://ascend.local/javascript/prototype.1.5.0.js :: anonymous :: line 916" data: no]'' thrown from function anonymous() in <http://ascend.local/javascript/prototype.1.5.0.js> line 916.
Exception ``[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.setRequestHeader]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://ascend.local/javascript/prototype.1.5.0.js :: anonymous :: line 916" data: no]'' thrown from function anonymous(url=string:"http://ascend.local/remote_fakeout/process.php") in <http://ascend.local/javascript/prototype.1.5.0.js> line 862.
Well, I’m using the json.js library from Douglas Crockford to parse the json results from the servlet and it sets a toJSONString method on each object. This ticket from Ruby On Rails trac provided the information that had eluded me for going on 28 hours.
This:
915: for (var name in headers)
916: if (typeof headers[name] != 'function')
917: },
Needs to become this:
915: for (var name in headers)
916: if (typeof headers[name] != 'function')
917: this.transport.setRequestHeader(name, headers[name]);
918: },
in prototype.js if you want to use the json.js library and not have Firefox throw exceptions like beads during Mardi Gras.
I hope to one day understand OOP enough to know how to solve these issues in under a day. Until then I’ll seek constant reprieve from the hourly compulsion to end my pain with a sweet gunpowder symphony due to my small brain, lack of raw talent, and inability to comprehend the obvious.
Yay.
Now I can get back to writing the web application I was supposed to be 30 hours into at this point. I suck.
Comments
-
You many want to update your code sections... you've got the code you need to add the wrong way around. Thanks for code... i was getting confused with it too.
-
Ffffoooohh!! THANKS very big!!!!
-
Thanks SO MUCH man!!! That was a great problem for me.
-
Very, very, very big thanks!!!!!
-
Most useful: I had this exception with Prototype 1.6 too. However, have a look here: http://www.prototypejs.org/learn/json Because Crockford implementation extends common Object class it is unsuitable for usage with Prototype. Prototype 1.5.1 and later feature an alternative JSON system.