jquery - Grabbing API via JSON and displaying -


i'm having trouble displaying data getting through api via json. code follows

var nextsessionapi = 'www.someapi.co.uk'; getsessionvalues(exhibitionid,sessionkey); function getsessionvalues(exhibitionid,sessionkey) {     jquery.getjson(nextsessionapi, function(data) {         jquery.each(data.data.session, function(index, sessions) {             console.log('success');             if(jquery.trim(sessions.startdate).exists()) {                  console.log(sessions.startdate);             };           });     }); } 

checking console getting api think code okay upto console.log('success');.

the api follows:

{     "parameters":{         "editionid":45,     },     "data":      [         {             "__type":"session:id",             "id":                 {                     "id":1251,                 },             "displayname":"some event",             "enddate":"\/date(1366712700000)\/",             "startdate":"\/date(1366711200000)\/"         }     ] } 

any assistance appreciated. p.s. go easy on me, js , json isn't strongest!

your fix:

var nextsessionapi = 'www.someapi.co.uk'; getsessionvalues(exhibitionid,sessionkey); function getsessionvalues(exhibitionid,sessionkey) {     jquery.getjson(nextsessionapi, function(data) {         jquery.each(data.data, function(index, sessions) {             console.log('success');             if(jquery.trim(sessions.startdate).exists()) {                  console.log(sessions.startdate);             };           });     }); } 

data.data list of sessions. data not conaint key: session


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -