我試圖使用NYT api來工作,但我不斷收到不同的錯誤。我試圖用這個無法獲取Ajax與鍵控api配合使用
$.ajax({
url:"http://api.nytimes.com/svc/news/v3/content/all/all/.json?api-key=xxxxxxxxxxxxxxxxxxxxx:xx:xxxxxxxxxx&callback=?",
dataType: 'jsonp',
success:function(json){
alert("Success");
},
error:function(){
alert("Error");
},
});
當我運行此我得到
Uncaught SyntaxError: Unexpected token :
我知道做跨域請求的影響,但我不知道如果我eveing這樣做的權利
它看起來像一個無效的URL。與jQuery無關。 – gdoron 2012-03-28 18:13:57
它看起來像是希望你的api-key的格式爲&api-key = {xxxxxxxxxxxxxxxxxxxxxxxx-xxxxx}?回調不是'?api-key' – Ohgodwhy 2012-03-28 18:22:05
@gdoron他的URL看起來無效嗎?除了?而不是api-key前面的&,這是構建NYT API的URI請求的正確方法。檢查他鏈接的API。 – Ohgodwhy 2012-03-28 18:22:57