Javascript 如何在ajax中获取数组的值
下面是获取jsonp请求的代码Javascript 如何在ajax中获取数组的值,javascript,jquery,arrays,ajax,Javascript,Jquery,Arrays,Ajax,下面是获取jsonp请求的代码 $.ajax({ type: "GET", url: pbxApi+"/confbridge_participants/conference_participants.json?cid="+circle, dataType: "jsonp", jsonpCallback: 'callback', contentType: "application/javascript",
$.ajax({
type: "GET",
url: pbxApi+"/confbridge_participants/conference_participants.json?cid="+circle,
dataType: "jsonp",
jsonpCallback: 'callback',
contentType: "application/javascript",
success: function(data) {
console.log(data);
}
});
这是请求
它输出数组中的所有数据
我只想输出特定的值
类似于uid的值
我想要返回的每个对象的输出uid。我该怎么做 如果您只想打印每个对象的uid,那么您可以遍历对象数组并单独访问每个uid
$.ajax({
type: "GET",
url: pbxApi+"/confbridge_participants/conference_participants.json?cid="+circle,
dataType: "jsonp",
jsonpCallback: 'callback',
contentType: "application/javascript",
success: function(data) {
for( var obj in data ) {
// Accessing object property using dot notation
console.log(obj.uid);
// Or square bracket notation
console.log(obj['uid']);
}
}
});
如果您希望做的只是打印每个对象的uid,那么您可以遍历对象数组并单独访问每个uid
$.ajax({
type: "GET",
url: pbxApi+"/confbridge_participants/conference_participants.json?cid="+circle,
dataType: "jsonp",
jsonpCallback: 'callback',
contentType: "application/javascript",
success: function(data) {
for( var obj in data ) {
// Accessing object property using dot notation
console.log(obj.uid);
// Or square bracket notation
console.log(obj['uid']);
}
}
});
如果您希望做的只是打印每个对象的uid,那么您可以遍历对象数组并单独访问每个uid
$.ajax({
type: "GET",
url: pbxApi+"/confbridge_participants/conference_participants.json?cid="+circle,
dataType: "jsonp",
jsonpCallback: 'callback',
contentType: "application/javascript",
success: function(data) {
for( var obj in data ) {
// Accessing object property using dot notation
console.log(obj.uid);
// Or square bracket notation
console.log(obj['uid']);
}
}
});
如果您希望做的只是打印每个对象的uid,那么您可以遍历对象数组并单独访问每个uid
$.ajax({
type: "GET",
url: pbxApi+"/confbridge_participants/conference_participants.json?cid="+circle,
dataType: "jsonp",
jsonpCallback: 'callback',
contentType: "application/javascript",
success: function(data) {
for( var obj in data ) {
// Accessing object property using dot notation
console.log(obj.uid);
// Or square bracket notation
console.log(obj['uid']);
}
}
});
尝试使用,因为此函数将迭代数据
变量:
$.each(data, function(i,e){
// do something here
console.log(e.id);
});
尝试使用,因为此函数将迭代数据
变量:
$.each(data, function(i,e){
// do something here
console.log(e.id);
});
尝试使用,因为此函数将迭代数据
变量:
$.each(data, function(i,e){
// do something here
console.log(e.id);
});
尝试使用,因为此函数将迭代数据
变量:
$.each(data, function(i,e){
// do something here
console.log(e.id);
});
您可以使用该函数返回数组的新修改版本
console.log(data.map(function(o) { return o.id; }));
您可以使用该函数返回数组的新修改版本
console.log(data.map(function(o) { return o.id; }));
您可以使用该函数返回数组的新修改版本
console.log(data.map(function(o) { return o.id; }));
您可以使用该函数返回数组的新修改版本
console.log(data.map(function(o) { return o.id; }));
是要为每个返回的对象输出uid,还是只为指定的对象输出uid?我要为每个返回的对象输出uid。我将如何做呢?使用
jQuery.each(数据、函数(索引、项){console.log(item.uid);})代码>要为返回的每个对象输出uid还是仅为指定的对象输出uid?我要为返回的每个对象输出uid。我将如何做呢?使用jQuery.each(数据、函数(索引、项){console.log(item.uid);})代码>要为返回的每个对象输出uid还是仅为指定的对象输出uid?我要为返回的每个对象输出uid。我将如何做呢?使用jQuery.each(数据、函数(索引、项){console.log(item.uid);})代码>要为返回的每个对象输出uid还是仅为指定的对象输出uid?我要为返回的每个对象输出uid。我将如何做呢?使用jQuery.each(数据、函数(索引、项){console.log(item.uid);})代码>