0

Here is my code getting jsonp request .

  $.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);

        }
        });

and here is the request

enter image description here

it outputs all the data in the array.

I want to output specific value only

like value of the uid.

i want output uid for each object returned. how will i do it?

3
  • do you want to output the uid for each object returned or for only a specified one? Commented Aug 18, 2015 at 3:00
  • i want output uid for each object returned. how will i do it? Commented Aug 18, 2015 at 3:01
  • 2
    use jQuery.each(data, function(index, item) { console.log(item.uid); }); Commented Aug 18, 2015 at 3:04

3 Answers 3

1

Try using .each(), as this function will iterate data variable :

 $.each(data, function(i,e){
   // do something here 
   console.log(e.id);
 });
Sign up to request clarification or add additional context in comments.

Comments

1

If all you are looking to do is to print the uid of each object you can iterate over the array of objects and access each uid individually

$.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']);
        }
    }
    });

Comments

1

You can use the map() function to return a new modified version of the array;

console.log(data.map(function(o) { return o.id; }));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.