If you're ever banging your head against a brick wall trying to figure out why your javascript code is returning 'undefined' when you attempt to 'alert()' a JSON object property...particuarly if you know that the server is returning an error code, try inspecting the the JSON object via 'responseText'
eg JSON: { "propertyName" : "propertyValue" }
Instead of accessing the property like:
alert(propertyName.propertyValue);
Try:
alert(responseText.propertyName.propertyValue);
The reason for this is: [google "can't access JSON object responseText"]
No comments:
Post a Comment