.ajax将无法在IE中运行

时间:2013-01-05 00:24:01

标签: jquery

  

可能重复:
  IE9 jQuery AJAX with CORS returns “Access is denied”

我的.ajax调用远程xml文件有点问题。在Safari而不是IE 9中正常工作。这可能是IE上的跨域问题,或者我的XML解析可能不好。

/* Last FM Scrobbler - get album XML details */
refreshArtwork('Snow Patrol', 'chasing cars');
function refreshArtwork(artist, track) {    
    $.ajax({
  type: 'POST',
  url: 'http://ws.audioscrobbler.com/2.0/',
  data: {
        method: 'track.getInfo',
        api_key: 'c88cc53549*******46f056dc05a745',
        artist: artist,
        track: track,
        //format: 'json'
        },
  dataType: 'xml', //set to json if above
  success: getLastfm
});
}

/* parse album XML from LastFM scrobbler */
function getLastfm(xml) {

lstAlbum = $(xml).find('title').text();
lstAlbumart = $(xml).find('image[size="large"]').text();
lstWiki = $(xml).find('summary').text();
lstURL = $(xml).find('url').eq(0).text();

alert(lstAlbumart);
$(".current").html('<div class="playing"><div class="title">' + '<img src="' + lstAlbumart + '" width="250" height="250" /></div></div>');

  }// end of getLastfm() function


//***** remote xml here for reference ******//

http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key=c88cc53549*******46f056dc05a745&artist=snow%20patrol&track=chasing%20cars

1 个答案:

答案 0 :(得分:0)

检查您的XML响应并确保XML有效。如果您使用的是XML,也不要执行跨域请求。如果使用跨域请求     dataType:'JSONP'