Welcome to WebmasterWorld Guest from 107.22.30.57

Forum Moderators: open

Message Too Old, No Replies

nsIXMLHttpRequest.setRequestHeader exception in Firefox

     
2:32 pm on Oct 11, 2005 (gmt 0)

New User

10+ Year Member

joined:Nov 1, 2003
posts:2
votes: 0


There is an older thread (now closed), [webmasterworld.com...] which is the first hit on google now when you search for the Firefox exception, nsIXMLHttpRequest.setRequestHeader . It looks something like :

Error: uncaught exception: [Exception... "Component returned failure code: 0x804b000f [nsixmlhttprequest.setrequestheader]" nsresult: "0x804b000f (<unknown>)" location: "JS frame :: [emp.kneedraggers.com...] :: populate_bike_makes :: line 173" data: no]

What the thread didn't mention is that actually this happens when you call setrequestheader() before calling open(), like so :

var http = new XMLHttpRequest();
http.setRequestHeader('X-Request-Type','DATA'); # exception raised here
http.open(method,url,async,username,password);

which, intuitively doesn't seem all that wrong. The fix is simply to call open first like :

var http = new XMLHttpRequest();
http.open(method,url,async,username,password);
http.setRequestHeader('X-Request-Type','DATA');

_

hope this saves someone the head scratching that it caused me!