从数组中获取 JSON 对象值
Get the JSON object Value from array
我无法将对象值获取到 html id 输入字段。
JSON return
// response from the call
{
"COLUMNS": ["cityname", "stateabbr"],
"DATA": [
["Culver City", "CA"]
]
}
$.each(response, function(index, zc) {
$("#cityname").append([zc[0]]);
$("#stateabbr").append([zc[0]]);
});
您必须针对每个问题进行修复。试试这个
$("#cityname").val(response.DATA[0][0]);
$("#stateabbr").val(response.DATA[0][1]);
我无法将对象值获取到 html id 输入字段。
JSON return
// response from the call
{
"COLUMNS": ["cityname", "stateabbr"],
"DATA": [
["Culver City", "CA"]
]
}
$.each(response, function(index, zc) {
$("#cityname").append([zc[0]]);
$("#stateabbr").append([zc[0]]);
});
您必须针对每个问题进行修复。试试这个
$("#cityname").val(response.DATA[0][0]);
$("#stateabbr").val(response.DATA[0][1]);