Bug Tracker

Modify

Ticket #6123 (closed bug: duplicate)

Opened 3 years ago

Last modified 3 years ago

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

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

Change History

Changed 3 years ago by chris.raethke

example of failure under ie

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 *

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 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to duplicate

Dup of #6298.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.