我收到错误:Uncaught SyntaxError:意外的标记<
我只是遇到了Google Trend URL的这个问题。其他网址工作正常。
function ajaxfun(){
$.ajax({
type: 'GET',
url: 'http://www.google.com/trends/fetchComponent?content=1&hl=en-US&q=fever&cid=TIMESERIES_GRAPH_0&export=3&US&cat=0-45',
dataType :"jsonp",
jsonp: false,
crossDomain: true,
error: function(data) {
console.log('error', data);
},
success: function(data) {
console.log('success', data);
},
complete: function() {
console.log('done');
}
});
}
答案 0 :(得分:1)
您实际上并没有收到json对象。它说,
<div id="report">
<div class="timeBandTitle">An error has been detected</div>
<div class="timeBandSubTitle">This page is currently unavailable. Please try again later.<br/> Please make sure your query is valid and try again.<br/> If you're experiencing long delays, consider reducing your comparison items.<br/> Thanks for your patience.</div>
Demo 使用开发人员工具进行检查,并在网络标签中查看。
答案 1 :(得分:0)
默认情况下,jQuery通过在网址末尾附加&_={timestamp}
来阻止jsonp的缓存。它会导致错误。添加cache:true
以防止它。