IE7 and XMLHttpRequest

I’ve spent a big part of the last week of my time lost in the abyss of IE 7 and XMLHttpRequest as part of MDL-28295 – it seems that under certain conditions a call to XMLHttpRequest crashes IE 7 when called from a child window….

Posting here in case someone else runs into this weird bug in the hope that it might save someone some time!
Pseudo code:
httpReq = new XMLHttpRequest();
httpReq.open(“POST”, url,false);
httpReq.setRequestHeader(‘Content-Type’, ‘application/x-www-form-urlencoded’);
httpReq.send(param);

When “param” contains something like this it works fine!
id=&a=11

but when “param” contains something like this – it crashes IE 7:
id=&a=11&cmi_corelesson_status=incomplete&cmicoreexit=suspend&cmi_suspend_data=|&attempt=1&scoid=28

Initially I thought the encoding might be the issue and encoding the params using encodeURI() seemed to work – but further testing found it was still an issue.

The fix was to re-structure the code so that it didn’t call the code from a child window but from within the “parent” window…. crazy….

Tags: ,

Comments are closed.