嗨,我正在尝试在错误发生时捕获错误,但 Json 有问题当轨道完美加载时,我收到了成功的答案,但在崩溃时我什么也没有
$.getJSON(apiUrl, function(data, error) {
index += 1;
if(data.tracks){
playerObj.tracks = playerObj.tracks.concat(data.tracks);
}else if(data.duration){
data.permalink_url = link.url;
playerObj.tracks.push(data);
}else if(data.creator){
links.push({url:data.uri + '/tracks'});
}else if(data.username){
if(/favorites/.test(link.url)){
links.push({url:data.uri + '/favorites'});
}else{
links.push({url:data.uri + '/tracks'});
}
}else if($.isArray(data)){
playerObj.tracks = playerObj.tracks.concat(data);
}
if(links[index] && (index % 18) != 0){
var mod = index % 18;
loadUrl(links[index]);
}else{
playerObj.node.trigger({type:'onTrackDataLoaded', playerObj: playerObj, url: apiUrl});
if (links[index]) {
loadMoreTracksData($player, links, key, index);
}
}
}).success(function() { console.log("second success"); }).error(function() { console.log("error"); });
有谁知道如何正确收听此 Api 中的错误。