我试图使用这个ajax调用:
var url = ' http://api.official.fm/tracks/D4lw?fields=streaming,cover&api_version=2';
jQuery.ajax({
url: url,
dataType: 'jsonp',
}).done(function( data ) {
//console.log(data);
}).fail(function(jqXHR, textStatus, errorThrown) {
if(useAlertMessaging) alert('error: ' + jqXHR.responseText);
});
它适用于IE10,但在IE9及以下版本中我收到此错误:
SCRIPT1004: Expected ';'
D4lw, line 1 character 9
控制台显示:
{"track":{"title":"Love Me As I Have Loved You (prod. Ritz Reynolds)","duration":75,"artist":"Mac Miller","url":"http://api.official.fm/tracks/D4lw?api_version=2","page":"http://official.fm/tracks/D4lw","buy_url":null,"rough_view_count":null,"rough_play_count":null,"rough_download_count":null,"streaming":{"http":"http://api.official.fm/tracks/D4lw/stream?api_version=2","rtmp":"rtmpe://fairtilize-174.fcod.llnwd.net/a2251/r2/mp3:/audio2/s/D4/D4lw_3594640?e=1378301197&h=8a551f822a7fbbc6fe07866626451bc3"},"cover":{"urls":{"large":"//cdn.official.fm/medias/pictures/tu/tuKi_large.jpg","medium":"//cdn.official.fm/medias/pictures/tu/tuKi_medium.jpg","small":"//cdn.official.fm/medias/pictures/tu/tuKi_small.jpg","tiny":"//cdn.official.fm/medias/pictures/tu/tuKi_tiny.jpg"},"id":"tuKi"},"project":{"name":"Mac Miller","url":"http://api.official.fm/projects/f8w6?api_version=2"}}}
光标指向第一个跟踪半色的前面:
{"track"
我能做些什么吗?
(我不控制我使用的网址)
我尝试删除ajax dataType,但结果是一样的。
答案 0 :(得分:1)
我在IE中的对象中添加额外的逗号时遇到了问题。试试这个:
jQuery.ajax({
url: url,
dataType: 'jsonp' // removed the comma from this line
}).done(function( data ) {
//console.log(data);
}).fail(function(jqXHR, textStatus, errorThrown) {
if(useAlertMessaging) alert('error: ' + jqXHR.responseText);
});