Jquery code to check an element is exist in json -
i want check element exist in json data doing
$.get('/geteststatus', getdata, function (data) { if (data != "" || data[0].status ) { });
where getdata
unique id
am getting error
typeerror: data[0] undefined if (data != "" || data[0].status) {}
json data contains 1 row value.it not contain multiple values.so used data[0]
checking
json data
{"id" : "12" , "status" : "gc", "_id" : objectid("52f3045873e7e96b18000005") }
since data
object, have use
if(!data || data.status){ }
Comments
Post a Comment