jquery - AJAX - Parsing JSON -
i attempting match id of table cell id specified within json file. if match found later description. everytime ran, skips straight error message. doing wrong?
function getjson(showid){ $.ajax({ type: 'get', url:'json/tvshows.json', datatype: 'jsonp', success: function(data){ $.each(data, function(key,tvshow){ tvshow.description; var tvshowid = tvshow.id; if (tvshowid == showid) { var description = tvshow.description; console.log(description); } }) }, error:function(){ console.log('error occured in getdescription'); } }); //ends ajax request }
you should using:
datatype: 'json',
Comments
Post a Comment