Bug Tracker

Opened 10 years ago

Closed 9 years ago

#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:
Blocked by: Blocking:

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 (1)

ajax_test_ie.html (1.1 KB) - added by chris.raethke 10 years ago.
example of failure under ie

Download all attachments as: .zip

Change History (3)

Changed 10 years ago by chris.raethke

Attachment: ajax_test_ie.html added

example of failure under ie

comment:1 Changed 9 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 *

xhr: window.XMLHttpRequest && (window.location.protocol !== "file:"
!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.

comment:2 Changed 9 years ago by dmethvin

Resolution: duplicate
Status: newclosed

Dup of #6298.

Note: See TracTickets for help on using tickets.