我正在从数据库中检索值并将其解析为 JSON。我的 JSON 数据格式就像..
[{"INCOMING":"09:09:49","INETCALL":"00:14:09","ISD":"00:05:50","LOCAL":"02:38:02","STD":"01:39:28"}]
我想将此 JSON 值分解为两个变量,一个是:
var toc=["INCOMING","INETCALL","ISD","LOCAL","STD"]
和像这样的另一个变量..
var callduration=["09:09:49","00:14:09","00:05:50","02:38:0","01:39:28"]
现在根据我的需要,我必须将它分成两个变量,因为我已经编写了一个 for 循环,但它不起作用。这是我的客户端代码..
$.ajax({
type: 'GET',
url: 'getdataduration',
async:false,
dataType: "text",
success: function(data) {
console.log(data);
var dbdata=JSON.parse(data);
console.log(dbdata);
for(var i=0,len=dbdata.length;i<len;i++){
$.isNumeric(dbdata[i]) ? callduration.push(dbdata[i]) : toc.push(dbdata[i]);
}
}
});
console.log(toc);
console.log(callduration);
请大家帮帮我。提前致谢..