I'm using jQuery 1.8 and I have an ajax call that returns JSON. If there's an error, it only returns { "status": "there was an error" }
otherwise, it returns a document which is the data that the ajax request means to load which will look something like { "document": { ... } }
On Firefox and Chrome the following code works, but on IE8 I'm getting an error saying data.status is null or not an object
(when the URL requested clearly does return a document and not just a status) which then causes the script to crash. Does anybody know how to get around this error message on IE8?
$.ajax({
url: "GanttLoader.ashx?action=loadGantt&gantt=" + current_selected_gantt + "&userId=" + userId,
context: document.body,
type: "GET",
dataType: "json",
success: function (data) {
if (data.status != null) {
if (data.status == "none") {
alert("no gantts found when attempted to load");
} else if (data.status == "locked") {
alert("this gantt is locked");
}
} else if (data.document != null) {
/* process the gantt */
}
},
error: function () {
alert("couldn't load gantt charts");
}
});