jQuery ajax() function is ignoring dataType parameter in Firefox
- by ccleve
I'm trying to use jQuery.ajax() to fetch some html, but Firefox is giving me a "junk after document element" error message. As explained here and here the problem seems to be that Firefox is expecting XML from the server, and when it doesn't parse correctly it throws the error. Here's my ajax code:
jQuery.ajax({
url: name,
dataType: "html",
success: function(result) {
console.log(result);
},
error: function (jqXHR, textStatus, errorThrown) {
console.log(errorThrown);
}
});
The server returns the html with these response headers:
Accept-Ranges bytes
Content-Length 2957
Last-Modified Tue, 02 Jul 2013 16:16:59 GMT
Note that there's no content-type header. I'm sure that adding one would solve the problem, but that's not an option.
The real problem is that Firefox appears to be ignoring the dataType: parameter in the ajax call. I've also tried adding contentType: and accepts: parameters, but it doesn't help.
What am I missing here? How do I force Firefox to process the response as plain text?