2013-03-29 77 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以防止它。

相關問題