[Javascript] pb with httprequest and firefox
Nick Fitzsimons
nick at nickfitz.co.uk
Tue Nov 28 11:53:56 CST 2006
On 28 Nov 2006, at 16:55:39, Bernu Bernard wrote:
> Hi list,
>
> I'm using XMLHttpRequest to get data from the server.
> It works but on Firefox only I got errors.
> The data I get are kind of JSON : { "q" : "something" } that is
> sent as text.
>
> I got the data in req.responseText but with an error :
>
> Error: not well-formed
> Source File: http://169.254.5.185/cgi-bin/mycgi
> Line: 1, Column: 1
> Source Code:
> {"q":""}^
>
> I could not figure out what to do.
>
> Any suggestions ?
>
> Bernard_______________________________________________
Hi Bernard,
It's very difficult to know what the problem could be from the
information you give. It's as if I said "I tried to go somewhere in
my car, but I didn't get there; what might the problem be?" Answers
could range from "You have no petrol" to "The road is closed" to "You
were struck by a meteorite on the way" to "You found your car had
been stolen when you went to start the journey" to... just about
anything. It's difficult even to offer a guess as to a solution;
continuing my example, suggesting I take a bus might help if the car
was stolen or had no petrol, but not if the road was closed.
It would help us to help you if you could put a page containing just
the code that isn't working correctly on a web server somewhere so
people can try various tests. If that's not possible, then posting
the code to the list will give somebody the chance to have a look and
maybe test it out, to see if they can find the problem.
Having said that, the 'Not well formed" error might be something to
do with Firefox trying to look at the data as XML. Make sure that
your CGI is setting an HTTP Content-Type header of "application/
json", or at least anything but an XML content type, and also make
sure that your script isn't trying to access the response through the
req.responseXML property, as either of those might trigger such an
error. Firefox tends to be much stricter about making sure things
like that are correct; Internet Explorer tends to not bother telling
you about such errors.
Regards,
Nick.
--
Nick Fitzsimons
http://www.nickfitz.co.uk/
More information about the Javascript
mailing list