Jack
Jack

Reputation: 7547

Jquery ajax not working in IE9 even with cors = true

This is my simple ajax code which works in FFX and Chrome but not in IE9. I am so much fed up of this browser I can't express. This is my jquery code:

   $.ajax({
                type: "GET",
                dataType: "xml",
                crossDomain: true,
                cache:false,
                url: "http://somedomain.net/folder/ap/connector.php"
            }).success(function (result, payPalresult) {
});

inside document.ready and connector.php has

Access-Control-Allow-Origin *

when I checked in Fiddler. Now this code works on FFX and Chrome but no ajax call is ever made in IE9

I even have this:

 $.support.cors = true;

Is there anything I am missing at this point? I am making an AJAX request from localhost

Upvotes: 2

Views: 2163

Answers (2)

user1999476
user1999476

Reputation: 21

If it's any help the workaround for IE9 without using xdr (in the trusted sites zone at any rate) and presuming CORS is true and crossDomain is true.

When doing a POST, do NOT serialize the form but instead extract all the data you need out of the form and set each as name:value pairs within the $ data container. Then it works.

HTH

Upvotes: 0

T.J. Crowder
T.J. Crowder

Reputation: 1074148

jQuery doesn't support IE's XDomainRequest object, which is what IE9 uses for CORS. Only IE10 does CORS with XMLHttpRequest. I believe there's a patch/plug-in you can find for jQuery that enables the XDomainRequest object. More information (including a link to a patch/plugin updated just six months ago, so fairly recent) in this ticket on the jQuery website.

Upvotes: 3

Related Questions