我一直在試圖從蒸汽api中提取數據,並沒有運氣,因爲我總是得到上述錯誤。這裏是我使用的代碼:跨域jquery ajax(Jsonp):未捕獲SyntaxError:意外的令牌:(冒號)
var steamurl = "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001/?key=[keyomitted]&account_id=38440257&Matches_Requested=10";
function populate_api(){
var json;
$.ajax({
'url': steamurl,
'dataType': "jsonp",
'success': function (data) {
alert('success');
json = data;
}
});
}
我省略了我的API密鑰。 我看了很多其他帖子,無法弄清楚問題出在哪裏。我曾嘗試使用Jsonp,普通的json,我也試過在steamurl
之後使用"&callback=?"
,但無濟於事。
你可以共享服務器的響應格式嗎 –
我不認爲API支持JSONP,只有JSON。 – Barmar
請參見https://developer.valvesoft ware.com/wiki/Steam_Web_API/Feedback#API_Considerations_for_Web_Developers –