javascript - Attempting to parse or assign JSON response: Response is read as [object Object] -


this question has answer here:

using flickr api, javascript/jquery, , ajax, have follow code:

        function getrequest(arguments)     {         var requestinfo;         $.ajax({             type: 'get',             url: flickrurl + '&'+ arguments + '&jsoncallback=jsoncallback',             async: false,             jsonpcallback: 'jsoncallback',             datatype: 'jsonp',             success: function (json)             {                 requestinfo = json;                 //parse attempt requestinfo = $.parsejson(json);                 //old method return json;             }         });         return requestinfo;     } 

when response received , attempt assign json (the response) data variable, requestinfo, (or if straight 'return json' line) error indicating returned value undefined. upon fooling success function, notice attempts parse response fails due 'json' being read [object object] instead of json response.

is response in array format? if not, how can point?

here example json response (there multiple types different requests needed receive needed information (flickr api):

{ "collections": {     "collection": [         {             "id": "122388635-72157643471284884",             "title": "test gallery 2",             "description": "test 2",             "iconlarge": "/images/collection_default_l.gif",             "iconsmall": "/images/collection_default_s.gif",             "set": [                 {                     "id": "72157643471292484",                     "title": "set 1",                     "description": ""                 }             ]         },         {             "id": "122388635-72157643469075734",             "title": "test gallery 1",             "description": "bing photos",             "iconlarge": "http://farm3.staticflickr.com/2888/cols/72157643469075734_b9a37df67c_l.jpg",             "iconsmall": "http://farm3.staticflickr.com/2888/cols/72157643469075734_b9a37df67c_s.jpg",             "set": [                 {                     "id": "72157643469056814",                     "title": "test gallery 1",                     "description": "bing backgrounds"                 }             ]         }     ] }, "stat": "ok" } 

so how pass received data other functions without disruption in data?

code should below

      success: function (collections)       {      $.each(collections,function(index,item){         var i=0;         $.each(item.conllection[i],function(index,item){         alert(item.id);         i++;         });         }); 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -