I am using jQuery.getJSON to get some data. I have an object called helpdesk.data.STATUS.MESSAGE.NOTLOGGEDIN which is created in a normal script tag. In the JSON returned by the call to getJSON, I am trying to reference helpdesk.data.STATUS.MESSAGE.NOTLOGGEDIN. I am using the .done method to capture the JSON and do something with it, and .error to catch any errors.
The JSON being returned looks perfectly valid, however it is going into the .error function with a status of 200 (OK).
If I change the reference to the object to a string, it goes into the .done method. Does anyone know of a way to reference an object which already exists within the page firing the getJSON request from the JSON being returned?
The returned JSON is:
{"builds": {"status": helpdesk.data.STATUS.FAILURE, "messages": [helpdesk.data.STATUS.MESSAGE.NOTLOGGEDIN]},"details": {"status": helpdesk.data.STATUS.FAILURE, "messages": [helpdesk.data.STATUS.MESSAGE.NOTLOGGEDIN]}}
Final code:
$.ajax("/helpdesk/resources/js/json/data.json.php", {"data": {"data": "styling-builds,details", "update": "update", "nojson": "nojson"}}).done(function(data) {
eval("data = " + data);
});