{"id":6252,"date":"2014-04-14T04:47:16","date_gmt":"2014-04-14T04:47:16","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/14\/ie8-bug-performing-post-ajax-call-over-ssl-collection-of-common-programming-errors\/"},"modified":"2014-04-14T04:47:16","modified_gmt":"2014-04-14T04:47:16","slug":"ie8-bug-performing-post-ajax-call-over-ssl-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/14\/ie8-bug-performing-post-ajax-call-over-ssl-collection-of-common-programming-errors\/","title":{"rendered":"IE8 Bug performing POST AJAX call over SSL-Collection of common programming errors"},"content":{"rendered":"<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/ace32c4dac4f82c9069676a242ba4fe3?s=32&amp;d=identicon&amp;r=PG&amp;f=1\" \/><br \/>\nstanleyhope<\/p>\n<p>The problem: I have a site with a recently installed SSL certificate that is very dependent on POST calls over AJAX. The site worked fine on Internet Explorer 8 before the SSL certificate, but now does not.<\/p>\n<p>Since I haven&#8217;t been able to get a good way to read any error messages, I haven&#8217;t been able to pin down where the bug is coming from. I will try to list as much as I know\/ have figured out, and I greatly appreciate any suggestions.<\/p>\n<p>What I know:<\/p>\n<ul>\n<li>On IE8, the site will not perform any AJAX POST calls that contain data<\/li>\n<li>The site worked fine until recently. The SSL certificate has been the most significant change since we originally had the site working in IE8<\/li>\n<li>If I change the AJAX call to use GET, or if I change it to use POST without sending any data, it reaches the server successfully. Unfortunately, the site requires using POST with data.<\/li>\n<li>The site works perfectly on Chrome, FF, Safari, Opera, and IE11. I haven&#8217;t had the opportunity to test IE10 or IE9 since we found the bug. We won&#8217;t really need to support &lt; IE8.<\/li>\n<li>I have tried to make a sample AJAX call using both vanilla JS and jQuery (code for both is below). Neither has worked for IE8, and both have worked for everything else.<\/li>\n<li>The AJAX call is being made to the same domain (and even the same PHP file) that is serving the main page, so there shouldn&#8217;t be any issues with cross domain AJAX calls (unless a bug is making it appear that way)<\/li>\n<li>Attempting to replicate the issue, I checked out another one of our sites that similarly uses SSL and has a lot of AJAX calls. It had the same issues (at least we are consistent), but apparently has never been brought to our attention because apparently that client doesn&#8217;t use IE8 in the workplace.<\/li>\n<li>When running on IE8, the call fails without throwing errors. In my vanilla JS test, I tried to alert the readyState and status on failure (which returned &#8216;4&#8217; and &#8216;0&#8217; respectively). Strangely enough, IE8 threw an error on the alert that showed the readyState and status.<\/li>\n<li>I am testing on an emulated version of IE8 (I have a Mac), so there is a possibility that my personal configuration on it is complicating things. However, I had a co-worker test it (also an emulator) and he received the same result, and I am almost certain that the people who have reported problems were using IE8. I have enabled native XMLHTTP support in my install of IE8 (that was apparently a common issue)<\/li>\n<li>Apparently another common issue with IE8 and AJAX is caching &#8211; I have tried setting the header &#8216;cache-control&#8217; to both &#8216;no-cache&#8217; and &#8216;public&#8217;, and neither works.<\/li>\n<\/ul>\n<p>Here is the vanilla JS code:<\/p>\n<pre><code>var xmlhttp = new XMLHttpRequest();\nxmlhttp.onreadystatechange=function(){\n  if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200){\n    \/*\n     * All the code that is supposed to run on success ... IE8 doesn't run anything in here\n     *\/\n  } else {\n    alert(xmlhttp.status); \/\/ This throws an error, but then displays '0'\n  }\n}\nxmlhttp.open(\"POST\",login_address,true);\nxmlhttp.setRequestHeader(\"Content-type\",\"application\/x-www-form-urlencoded\");\nxmlhttp.send(\"email=\"+dataVar.email+\"&amp;password=\"+dataVar.password);\n<\/code><\/pre>\n<p>Here is the jQuery version:<\/p>\n<pre><code>$.ajax({url:login_address,\n  type: 'POST',\n  data: dataVar,\n  headers: { \"cache-control\": \"no-cache\" },\n  success: function(msg){    \n    \/*\n     * All the code that is supposed to run on success ... IE8 doesn't run anything in here\n     *\/\n  }, \n  error: function (jqXHR, textStatus, errorThrown){\n    alert('ErrorThrown: '+errorThrown+' ErrorStatus: '+textStatus); \/\/ This returns 'ErrorThrown: Unknown ErrorStatus: Unknown'\n  }\n});\n<\/code><\/pre>\n<p>If you need to try out an example yourself, you can go to https:\/\/www.kenkochallenge.com\/ and click on the Login link in the top right. You can enter anything in the email and password fields &#8211; When you click Login, if the call to the server was successful, the form will give an error message that your username and password didn&#8217;t match.<\/p>\n<p>Again, thank you for any suggestions! If anyone has an idea, please let me know and I will try it out.<\/p>\n<\/li>\n","protected":false},"excerpt":{"rendered":"<p>stanleyhope The problem: I have a site with a recently installed SSL certificate that is very dependent on POST calls over AJAX. The site worked fine on Internet Explorer 8 before the SSL certificate, but now does not. Since I haven&#8217;t been able to get a good way to read any error messages, I haven&#8217;t [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-6252","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=6252"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/6252\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=6252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=6252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=6252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}