我正在获取查询结果,遍历它们并尝试在将它们输出到页面之前进行一些调整。我似乎无法让+=
操作员在所有浏览器中正常工作。虽然,-=
运营商似乎工作正常。基本上,+=
只是串联。
我试过强制结果为数字,但这似乎也不起作用。
var str = '<h2>The Score</h2>'
for (var i = 0; i < data.message.DATA.length; i++) {
var theName = data.message.DATA[i][columnMap.ENTRYID]
switch (theName)
{
case "jrd":
newname = "Carmen";
theNumber = data.message.DATA[i][columnMap.TOTALCOUNT] -= 110;
if ($('#entryid').val() == "jrd"){
$('#recordcount').text(theNumber);
}
break;
case "ejf":
newname = "Elijah";
theNumber = Number(data.message.DATA[i][columnMap.TOTALCOUNT] += 50);
if ($('#entryid').val() == "ejf"){
$('#recordcount').text(theNumber);
}
break;
}
str += '<b>'+newname+'</b>'
str += ' '+theNumber+'<br/>'
}
$("#score").html(str)
}
这是从我的 ColdFusion 查询返回的数据。我$.ajax()
用来打电话给CFC...
{"message":{"COLUMNS":["ENTRYID","TOTALCOUNT"],"DATA":[["ejf","62"],["gdd","52"],["jrd","215"],["kpf","70"]]},"error":false}