Max Max - 8 days ago 5
Ajax Question

JQuery AJAX trying to parse XML even with "dataType" : "JSON"

As the title suggests, I have the following:

$.ajax({
"url" : ...
, "type" : "GET"
, "dataType" : "JSON"
, "success" : function(response_data) {
that.data = response_data;
success(response_data);
}
, "onerror" : function(data) {
console.log(JSON.stringify(data));
}
});


But when I run it, I get

XML Parsing Error: syntax error Location: moz-nullprincipal


Looking at firebug, I see that the request was

Accept application/json, text/javascript, */*; q=0.01
Accept-Encoding gzip, deflate
Accept-Language en-us,en;q=0.5
Cache-Control max-age=0
Connection keep-alive
Host localhost:8888
Referer http://localhost:8888/
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101 Firefox/13.0.1
X-Requested-With XMLHttpRequest


Any ideas?

Max Max
Answer

Ok great thanks to everyone tried to answer this.

But it turns out, as usual, I noob'ed out here.

The XML parsing error shown in firebug is not actually an error with the code, and firebug's failed attempt to guess it's XML and parse it.

My problem was elsewhere in the program and it was solved.

Upper vs lower case "JSON" did not make a difference.

Max