{"id":175,"date":"2011-07-13T22:39:26","date_gmt":"2011-07-13T22:39:26","guid":{"rendered":"http:\/\/danmarsden.com\/blog\/?p=175"},"modified":"2011-07-13T22:39:26","modified_gmt":"2011-07-13T22:39:26","slug":"ie7-and-xmlhttprequest","status":"publish","type":"post","link":"https:\/\/danmarsden.com\/blog\/2011\/07\/13\/ie7-and-xmlhttprequest\/","title":{"rendered":"IE7 and XMLHttpRequest"},"content":{"rendered":"<p>I&#8217;ve spent a big part of the last week of my time lost in the abyss of IE 7 and XMLHttpRequest as part of <a href=\"http:\/\/tracker.moodle.org\/browse\/MDL-28295\" target=\"_blank\">MDL-28295<\/a> &#8211; it seems that under certain conditions a call to XMLHttpRequest crashes IE 7 when called from a child window&#8230;.<\/p>\n<p>Posting here in case someone else runs into this weird bug in the hope that it might save someone some time!<br \/>\nPseudo code:<br \/>\nhttpReq = new XMLHttpRequest();<br \/>\nhttpReq.open(&#8220;POST&#8221;, url,false);<br \/>\nhttpReq.setRequestHeader(&#8216;Content-Type&#8217;, &#8216;application\/x-www-form-urlencoded&#8217;);<br \/>\nhttpReq.send(param);<\/p>\n<p>When &#8220;param&#8221; contains something like this it works fine!<br \/>\nid=&amp;a=11<\/p>\n<p>but when &#8220;param&#8221; contains something like this &#8211; it crashes IE 7:<br \/>\nid=&amp;a=11&amp;cmi_<em>core<\/em><em>lesson_status=incomplete&amp;cmi<\/em><em>core<\/em><em>exit=suspend&amp;cmi<\/em>_suspend_data=|&amp;attempt=1&amp;scoid=28<\/p>\n<p>Initially I thought the encoding might be the issue and encoding the params using encodeURI() seemed to work &#8211; but further testing found it was still an issue.<\/p>\n<p>The fix was to re-structure the code so that it didn&#8217;t call the code from a child window but from within the &#8220;parent&#8221; window&#8230;. crazy&#8230;.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;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 &#8211; it seems that under certain conditions a call to XMLHttpRequest crashes IE 7 when called from a child window&#8230;. Posting here in case someone else runs into this weird [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,12],"tags":[3,5],"class_list":["post-175","post","type-post","status-publish","format-standard","hentry","category-moodle","category-scorm","tag-moodle","tag-scorm"],"_links":{"self":[{"href":"https:\/\/danmarsden.com\/blog\/wp-json\/wp\/v2\/posts\/175","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/danmarsden.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/danmarsden.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/danmarsden.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/danmarsden.com\/blog\/wp-json\/wp\/v2\/comments?post=175"}],"version-history":[{"count":1,"href":"https:\/\/danmarsden.com\/blog\/wp-json\/wp\/v2\/posts\/175\/revisions"}],"predecessor-version":[{"id":176,"href":"https:\/\/danmarsden.com\/blog\/wp-json\/wp\/v2\/posts\/175\/revisions\/176"}],"wp:attachment":[{"href":"https:\/\/danmarsden.com\/blog\/wp-json\/wp\/v2\/media?parent=175"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/danmarsden.com\/blog\/wp-json\/wp\/v2\/categories?post=175"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/danmarsden.com\/blog\/wp-json\/wp\/v2\/tags?post=175"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}