json.js integration problem in FireFox

By ajaxtrend

I was just writing some sample code for an database based AJAX application. I have a servlet that takes care of database communication. I just though to use json and it really helped me a lot to to minimize the amount of work needed to display details of data extracted from DB in a browser. I was using Prototype.js provided utility functions to create an XHR request and other utility functions.

When I started integrating with json.js, I get bunch of error in my browser and it did not work at all.

[Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.setRequestHeader]” nsresult: “0×80070057 (NS_ERROR_ILLEGAL_VALUE)” location: “JS frame :: http://localhost:8080/AT/htmls/prototype.js :: anonymous :: line 919″ data: no]

I could not able to trace it why such error occured. Find some information about this from google search. On debugging, I found that in prototype.js, which setting headers some line no 915,

this.transport.setRequestHeader(name, headers[name]);

As JSON has extended with toJSONString function so this we need to remove this from setHeaders method.

I just manipualted prototype.js

for (var name in headers)
{

if(name != ‘toJSONString’){

this.transport.setRequestHeader(name, headers[name]);
}
}

Now my code started working both in FF and as well as with IE.

Leave a Reply