[Javascript] JSON element has no properties - how to validate?
Scott Reynen
scott at randomchaos.com
Wed Nov 21 08:27:49 CST 2007
On Nov 21, 2007, at 1:20 AM, Michael Borchers wrote:
> I get an httpRequest(myRequest.response) formatted by php into a
> JSON format, it looks like this:
>
> [{"price":42.4535153,"error":null}]
>
> I handle it this way so far:
>
> var transport = eval(myRequest.response);
> var transportError = transport[0].error;
> var transportPrice = transport[0].price;
>
> Since "error" is empty (null) I get a warning: "transport has no
> properties"!
What makes you think error being empty is causing this warning? It
certainly sounds like transport itself is empty. I suggest you double
check that myRequest.response and transport actually contain what you
think they do.
Peace,
Scott
More information about the Javascript
mailing list