更新时间:2022-05-18 21:58:16
不要解析它:$.ajax
为您解析了它.只需使用为您的success
回调函数提供的参数,这就是已解析的数组.
Don't parse it : $.ajax
parsed it for you. Just use the argument which is given to your success
callback, this is the parsed array.
如果您的浏览器无法检测到它的JSON,请添加dataType
参数.
If your browser can't detect it's JSON, add the dataType
argument.
还请注意,您不必自己管理i
计数器:一个由each
传递:
Note also that you don't have to manage the i
counter yourself : one is passed by each
:
dataType: 'json',
success: function(sum){
$('input.hj').each(function(i){
if (sum[i] > 0) {
$(this).val(sum[i]);
}
});
}