JSON Fields are Undefined (Javascript) -
i'm getting json servlet , turning responsetext json object using json.parse(). chrome developer tools shows json object having data want, when try access bunch of 'undefined's.
am not interpreting data correctly?
screenshot of chrome developer tools:
and briefly, code output data:
(var = 0, len = jsonobj.length; < len; ++i) { // setup result... var resultrow = document.createelement("tr"); resultstable.appendchild(resultrow); var result = jsonobj[i]; // name var covercell = resultrow.insertcell(0); covercell.innerhtml = result.name; }
jsondata seen in screenshot passed output function jsonobj.
the key trying access seems have @
character @ front. since @
character not valid identifier , therefore can't use dot-notation, can retrieve value using bracket notation:
covercell.innerhtml = result['@name'];
Comments
Post a Comment