Ticket #6123 (closed bug: duplicate)
IE ajax methods don't return XMLHttpRequest in v1.4.x
| Reported by: | chris.raethke | Owned by: | |
|---|---|---|---|
| Priority: | Milestone: | 1.4.2 | |
| Component: | ajax | Version: | 1.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
From v1.4.0 onwards, any calls to $.ajax(), $.get(), $.getJSON() and $.post() return null instead of an XMLHttpRequest under Internet Explorer 7.
Attachments
Change History
Changed 3 years ago by chris.raethke
-
attachment
ajax_test_ie.html
added
comment:1 Changed 3 years ago by copleykj
This issue seems to be that IE doesn't properly implement the XMLHttpRequest object. Upon testing if window.XMLHttpRequest exists it is reported as true but upon trying to create a new instance it reports that it doesn't. I have personally fixed this for myself with a simple modification.
This code starts on line 4952 in the development version if you want to modify so it's useable. If you do, I would recommend using something like http://refresh-sf.com/yui/ to compress it before you use it on your site
* Original Code *
| !window.ActiveXObject) ? |
function() {
return new window.XMLHttpRequest();
} : function() {
try {
return new window.ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {}
},
* New Function *
xhr: window.ActiveXObject ?
function() {
try {
return new window.ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {}
} : function() {
return new window.XMLHttpRequest();
},
With the modification it checks to see if the browser implements the activex object xmlhttp instead and if available uses it first and XMLHttpRequest as a last resort. This may not be the best fix, BUT I need my sites to work in ALL major browsers as most people do.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

example of failure under ie