如何計算我的請求的對象?如何計算JavaScript中的json對象
我正在使用ajax並向此URL請求json數據pbxApi+"/conference/participants/"+circle+"/"+data.conference+"/"+data.uniqueid+'?jsonp=response';
我想計算響應的對象。
這是我的代碼
var uri = pbxApi+"/conference/participants/"+circle+"/"+data.conference+"/"+data.uniqueid+'?jsonp=response';
getJsonData(uri, function(res){
console.log(res.length);
});
這是我functiion:
var getJsonData = function(uri,callback){
$.ajax({
type: "GET",
dataType: "jsonp",
url: uri,
jsonpCallback: 'response',
cache: false,
contentType: "application/json",
success: function(json){
callback(json);
}
});
}
這是我的迴應
response({"_id":"561713a78693609968e3bbdd","event":"ConfbridgeJoin","channel":"SIP/192.168.236.15-00000024","uniqueid":"1444352918.94","conference":"0090000293","calleridnum":"0090000288","calleridname":"0090000288","__v":0,"status":false,"sipSetting":{"accountcode":"0302130000","accountcode_naisen":"201","extentype":0,"extenrealname":"UID1","name":"0090000288","secret":"Myojyo42_f","username":"0090000288","context":"innercall_xdigit","gid":101,"cid":"0090000018"}})
謝謝:)
你所說的 「算對象」 呢? –
在響應中,如果沒有'json'的'結構',回答非常困難 – Anonymous0day
我加了我的回覆@ Anonymous0day – uno