Monday, 12 December 2011

Cannot read JSON object property - MVC AJAX

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:




The reason for this is: [google "can't access JSON object responseText"]

No comments:

Post a Comment