JSON node in jquery, Uncaught TypeError: Cannot read property '0' of undefined -


how read json nodes below jquery code, currently, getting "uncaught typeerror: cannot read property '0' of undefined" in firebug, please let me know doing wrong.

jquery

$(document).ready(function() {   $('#search_btn_2').click(function(){  var queryvalue = $('#search_string_2').val();  $('.my-div').hide();  $.getjson( "${kb_endpoint_url}",              { search_query : queryvalue }           )  .done(function( data )  { console.log("success:"+queryvalue+":"+data);  alert(data.docs[0].title);                      $('.my-div').html('<a href="'+data.docs[0].type+'">'+data.docs[0].title+'</a>');   })  .done(function() { console.log("second success"); })  .fail(function() { console.log("error"); })  .always(function() { console.log("finished"); $('.my-div').show(); });                     });  }); 

json

{    "response":{       "start":0,       "docs":[          {             "summary":"image/img1.jpg",             "id":"17",             "title":"varun",             "votecount":0,             "_version_":1192256,             "type":"user"          }       ],       "numfound":1    },    "responseheader":{       "status":0,       "qtime":1,       "params":{          "indent":"true",          "q":"varun",          "wt":"json"       }    } } 

data.docs undefined. per json structure, you're looking data.response.docs.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -