2012-07-05 191 views
0

我有以下JQuery的AJAX请求时,它在Chrome中工作正常,但是当我在IE浏览器进行测试,它返回undefined为什么Ajax请求不在IE中工作?

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

[jQuery ajax responseText'undefined'](http://stackoverflow.com/questions/5460275/jquery-ajax-responsetext-undefined) – 2012-07-05 14:28:00

+2

的可能重复,如async所述:false是必需的。 – 2012-07-05 14:29:40

+0

这是跨域AJAX吗?如果是这样检查出来http://forum.jquery.com/topic/cross-domain-ajax-and-ie#14737000000729148 – 2012-07-05 14:31:01

回答

1

你有没有尝试过这样的:

$(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); 
    } 
} 

是否只是测试它工作正常 也摆脱的console.log的呼叫,如果开发者工具arenot打开它在IE浏览器不会工作。

+0

谢谢!这固定它! :) – CallumVass 2012-07-06 07:09:28