这行代码出现意外的标识符错误:var player[data[x].split("|",1)] = data[x].split("|")[1];
响应数据采用以下格式:
Mike Trout|0\nRyan Braun|0\n...
这是完整的 JS 函数:
function updateChance(round, pickNumber)
{
$.ajax({
type: "GET",
data: {round: round, pickNumber: pickNumber},
url: "./lib/updatechance.php",
dataType: "html",
async: false,
success: function(response)
{
var data = response.split("\n");
for (var x=0; data.length; x++)
{
var player[data[x].split("|",1)] = data[x].split("|")[1];
}
for (var r = 1; r < $('#battersTable').rows.length; r++){
//do something with player
}
}
});
}