2013-03-29 76 views
1

我收到错误:未捕获的SyntaxError:意外的标记<JSON错误:未捕获的SyntaxError:意外的标记

我只遇到此问题与谷歌趋势的网址。其他网址工作正常。

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'); 
    } 
    }); 
} 
+1

'data'包含什么? –

回答

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 检查与开发工具,看看它在网络标签。

+0

完全正确..how我可以解决这一 – Prashobh

+0

我have't使用趋势API,但发现这个链接.. http://stackoverflow.com/questions/7805711/javascript-json-google-trends-api。你可能会在这里找到有用的东西 – SachinGutte

0

jQuery的默认通过在URL的末尾追加&_={timestamp}防止JSONP的缓存。它会导致错误。添加cache:true以防止它。

相关问题