javascript - JSON object returned but not accessible via $.ajax() -
i have asp.net mvc web api calling $.ajax() method. correct json returned api, object not accessible. error received in console when trying log value "name" is:
uncaught typeerror: cannot read property 'name' of undefined
json:
[{"id":2,"name":"thom","picture":"thom.jpg","about":"i'm guy. profile. quit staring , out of here.","location":"london"}]
jquery:
$.ajax({ cache:false, type: 'get', datatype: 'json', url: 'http://localhost:3235/users/searchusers?callback=?&searchstring=' + searchstring, complete: function (data) { console.log(data[0].name); } });
any appreciated. thanks!
i think mean use success
function. complete
function doesn't take data
parameter.
Comments
Post a Comment