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

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -