AJAX problems with jQuery and IE 7

August 15, 2011

blog

I spent the day debugging a specific Javascript error in Internet Explorer. It seemed to have problems with fetching a JSON data file through $.ajax. For reference, the solution was to force IE to use ActiveX for xhr (found by Bjoggi at the jQuery forums):

$.ajaxSetup({ xhr: function() { if ($.browser.msie) { return new ActiveXObject("Microsoft.XMLHTTP"); } else { return new XMLHttpRequest(); } } });

Hope this helps anyone else - since searching for "ajax ie" results in a whole can of worms...