How to read JSONP response data in name and value pairs in Jquery ajax.?

I am trying to read JSON file from other domain with JSONP technique

Here is the JSON

callback({
  "response":{"docs":[
      {
        "FirstName":"qwe",
        "LastName":"asd",
        "Age":"30"},
      {
        "FirstName":"zxc",
        "LastName":"bnm",
        "Age":"40"},

        .
        .
        .
      {
        "FirstName":"poi",
        "LastName":"lkj",
        "Age":"20"},
      ]},
})

Here is the Jquery code

$.ajax({
                    type: "GET",
                    url: "http://qqq.com/",
                    crossDomain: true,
                    jsonpCallback: 'callback',
                    contentType: "application/json; charset=utf-8",
                    dataType: "jsonp",
                    success: function (msg) {
                         $.each(msg.response.docs, function (key, value){
                              alert(key +"is"+value);
                    }
         });

From the above code i am expecting to get the alert output as

FirstName is qwe
LastName is asd 
and so on

But i am getting the alert as

0 is [object Object]
1 is [object Object]
and so on

can i know what i need to do to get the out put as my expectation like

FirstName is qwe
LastName is asd 

Thanks in advance


Source: json

Leave a Reply