jquery - JSON Return - key causing error warning -


i'm getting set of results es (elastic search) in json, i'm iterating through expect , printing out results onto web page. it's iterating through them fine , working expected i'm not sure if there hidden problem or prevented finding out why problem being raised.

the error - (chrome)

error message - chrome

any insight on getting rid of great, wonders ocd...

thanks.

return json

{ "took": 16, "timed_out": false, "_shards": {     "total": 5,     "successful": 5,     "failed": 0 }, "hits": {     "total": 13016,     "max_score": 9.844111,     "hits": [         {             "_index": "uber",             "_type": "uber",             "_id": "ruelvw41s7-3aobcwkkxbq",             "_score": 9.844111,             "_source": {                 "pty_desig_suffix": "|",                 "pty_forename": "nathan",                 "pty_name_suffix": ", |",                 "pty_surname": "smith",             }         }, 

it's saying data.hits.hits[i] undefined. log value of data.hits.hits[i] first (and maybe meant data.hits[i] ?). should put check in place data.hits.hits[i] != null && data.hits.hits[i] != undefined

in case, if do:

console.log(hits); console.log(hits.hits); console.log(hits.hits[i]); // 1 in iteration 

you should able spot things going wrong.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -