CallumVass
CallumVass

Reputation: 11448

Why doesnt this Ajax request work in IE?

I have the following JQuery AJAX request, it works fine in Chrome but when I test in IE, it returns undefined:

$.ajax({
    url : 'http://pipes.yahoo.com/pipes/pipe.run?_id=26650603c42f41d78bfb5c5c740747d3&_render=json&_callback=?',
    dataType : 'xml',
    complete : function(data) {
        console.log(data.responseText);
    }
});

Upvotes: 0

Views: 152

Answers (2)

Suave Nti
Suave Nti

Reputation: 3747

Did you tried like this:

 $(document).ready(function(){
    $.ajax({
        url : 'http://pipes.yahoo.com/pipes/pipe.run?_id=26650603c42f41d78bfb5c5c740747d3&_render=json&_callback=pipeCallback', 
        dataType : 'jsonp',
        complete : function(data) {
            //alert(data.responseText);
            //console.log(data.value);
        },
         error: function (xhr, status, error) {
                alert(error);
            }
    });
});
function pipeCallback(d){
    data = d;
    //console.debug(d);
    var arts = d.value.items;
    for (var i=0; i<arts.length; i++)
    {
    var a = document.createElement("a");
    a.setAttribute("href", arts[i].link);
    a.innerHTML = "<h1>" + arts[i].title + "</h1>"
    var dv = document.createElement("div");
    dv.innerHTML = arts[i].description;
    document.body.appendChild(a);
    document.body.appendChild(dv);
    }   
}

Have just tested it is working fine also get rid of console.log calls, if the developer tools arenot open it wont work in IE.

Upvotes: 1

Joseph Szymborski
Joseph Szymborski

Reputation: 1283

It seems it's a matter of browser security settings:

Internet explorer just doesn't allow CORS (at least in -IE7) as a matter of security. IE8+ seems to be able to do XDR, however.

Upvotes: 0

Related Questions