对此问题的任何帮助将不胜感激! 我有问题迭代这个json api并在我的控制台中出错:
未捕获的SyntaxError:意外的令牌:,“成功”之后:true,
如何使用javascript或jquery迭代这个json api?
{
"success": true,
"data": {
"match": [{
"id": "87309",
"home_name": "Viktoria Plzen U21",
"away_name": "Slavia Praha U21",
"score": "0 - 0",
"ht_score": "",
"ft_score": "",
"et_score": "",
"time": "26",
"league_id": "0",
"status": "IN PLAY",
"added": "2018-04-23 09:05:02",
"last_changed": "2018-04-23 09:26:01",
"home_id": "0",
"away_id": "0",
"events": false,
"league_name": null
},
{
"id": "87308",
"home_name": "Karvina U21",
"away_name": "Slovan Liberec U21",
"score": "1 - 0",
"ht_score": "",
"ft_score": "",
"et_score": "",
"time": "26",
"league_id": "0",
"status": "IN PLAY",
"added": "2018-04-23 09:05:02",
"last_changed": "2018-04-23 09:26:01",
"home_id": "0",
"away_id": "0",
"events": false,
"league_name": null
}]
}
}
以及到目前为止的代码:
$.ajax({
url: url,
dataType: 'JSONP',
jsonpCallback: 'callbackFnc',
type: 'GET',
async: false,
crossDomain: true,
success: function (data) { },
failure: function () { },
complete: function (data) {
if (data.readyState == '4' && data.status == '200') {
if (data.match) {
for (var i = 0; i < data.match.length; i++) {
console.log( data.match[i].id );
}
}
} else {
errorLog.push({ IP: Host, Status: 'FAIL' })
}
}
});