我正在尝试获取一个使用PHP进行json_encode处理的文件。文件在另一个域上,无论我尝试什么都没有得到任何结果。
$.ajax({
url: 'http://cdn2.realhardstyle.nl/data/radio/nowplaying.rhr',
dataType: 'jsonp',
success: function(data){
alert('test');
}
});
例如,我只需要[ID]的值,但我什么都没有得到,没有错误,没有控制台日志提到任何可能是问题的内容,但警报也没有显示出来。
我在这里做错了什么?
该url为您提供JSON资源,而不是jsonp
$.ajax({
url: 'http://cdn2.realhardstyle.nl/data/radio/nowplaying.rhr',
dataType: 'json',
success: function(data){
$('body').append(data[0].id);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>