Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Parsing Error: not well-formed in FireFox but good in Chrome

Tags:

I using jQuery Ajax like below:

$.ajax({
url: 'servlet/*****Servlet',
      dataType: "text",
      success: function(data) {
        var subareaCoordsPGs = preprocessCoords(data);
      }
    });

it works good even i did not set the dataType in Chrome, however, it failed in FF with XML parsing error.

Response Headersview source
Server Apache-Coyote/1.1
Transfer-Encoding chunked
Date Tue, 04 Oct 2011 00:08:08 GMT
Request Headersview source
Host localhost:8080
User-Agent Mozilla/5.0 (Windows NT 5.2; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Accept text/plain, /; q=0.01
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,;q=0.7
Connection keep-alive
X-Requested-With XMLHttpRequest
Referer http://localhost:8080/
*/
Cache-Control max-age=0

XML Parsing Error: not well-formed Location: moz-nullprincipal:{2f6a8381-b987-448b-88c2-e89c4e13440b} Line Number 1, Column 4:

[email protected] -33.9353900931769,151.247877472978 -33.9360784582012,151.24...
------^

after searched, i know it is good to set the proper data type, i want it to be parsed just as normal text, but why Intelligent Guess not works in FF, even i set it's type is "text" explicitly?

like image 897
qc999 Avatar asked Oct 04 '11 00:10

qc999


1 Answers

Your server is not returning a content-type, so Firefox assumes that since this is _XML_HttpRequest your response might be XML and tries to parse it. When that fails, it stops trying and reports that this wasn't XML after all.

Chrome likely does the same but doesn't report anything.

I suggest actually sending a Content-Type header indicating what your data is.

like image 156
Boris Zbarsky Avatar answered Sep 22 '22 22:09

Boris Zbarsky