从Dota 2匹配历史API调用JSON时未捕获的SyntaxError

时间:2014-03-28 15:28:00

标签: javascript jquery ajax json

我尝试使用Dota 2匹配API(在此处找到http://dev.dota2.com/showthread.php?t=47115)为Steam用户调用匹配历史记录。

我已尝试使用$.ajax$.getJSON,但这两种方法都会出错。

铬:
Uncaught SyntaxError: Unexpected token : api.Steampowered.com/:2

并在FireFox中:
SyntaxError: missing ; before statement V001:2

查看代码错误的行显示了我想要获取的JSON数据 { "result": { "status": 1, "num_results": 1, "total_results": 500, "results_remaining": 499, "matches": [ { "match_id": 583031457, "match_seq_num": 530629087, "start_time": 1396000424, "lobby_type": 0, "players": [ { "account_id": 4294967295, "player_slot": 0, "hero_id": 14 }, etc....

为什么会出现此错误,我该怎么办才能解决此问题?

以下是我的javascript的最新版本(多次尝试修复后):

var apiURL = "https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001/?";
var apiKey = "key=*My account's API key*";
var steamID = "&account_id=37828178";
var matchesNum = "&matches_requested=1";
var callBack = "&jsoncallback=?";

$.ajax({
    url: apiURL + apiKey + steamID + matchesNum + callBack,
    dataType: 'json',
    success: function (data) {
        //Code using the data I've accessed
    }
});`

0 个答案:

没有答案