Well ... you're about 3/4 of the way ... you already have JSON as text.
The problem is that you seem to process this string as if it were already a JavaScript object with properties associated with the passed fields.
This is not ... its just a string.
Queries like "content = data [x] .Id;" required to crash because JavaScript does not find these properties attached to the line it is looking at ... again, its just a line.
You should simply parse the data as JSON via ... yup ... the parse method of the JSON object.
myResult = JSON.parse(request.responseText);
Now myResult is a javascript object containing the properties that were passed through AJAX.
This should allow you to handle it the way you are trying to do.
It seems like JSON.parse was added when ECMA5 was added, so something pretty modern should be able to handle this initially ... if you need to handle fossils, you can also try using external libraries like jQuery or JSON2 .
For the record, Andy E has already answered for someone else HERE .
edit - I saw a request for "official or reliable sources", and probably one of the encoders that I think is most likely would be John Resig ~ ECMA5 JSON ~ I would contact the actual ECMA5 specification regarding native JSON support, but I would rather handed someone to a captain like Resig, not a dry specification.
Steve Jun 26 '13 at 20:44 2013-06-26 20:44
source share