Closed Bug 448347 Opened 16 years ago Closed 16 years ago

AJAX XMLHttpServer object does not behave like in ie7 or Safari 3.1

Categories

(Core :: XML, defect)

1.9.0 Branch
x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 311724

People

(Reporter: marc.personeni, Unassigned)

References

()

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1

I have set up the web page above to demonstrate the problem.
On initialization, a small function is called, which places three AJAX requests and stores each result in one of three nominated tags (namely sandboxStatus, sandboxUser and sandboxTime).
The code works well with ie7 and Safari 3.1.2.
Apparently it starts alright with Firefox as well, but Firefox logs errors in the console upon reception of the data.
It looks like FireFox decides my data is not good enough for me. :-)


Reproducible: Always

Steps to Reproduce:
1. Open above link with ie7 and see it run
2. Open above link with Safari 3.1.2 and see it run
3. Open above link with Firefox 3.0.1 and see it not run (check error console)
Actual Results:  
Firefox displays:
Sandbox Status is: unknown
Sandbox User is: unknown
Sandbox Time is: unknown

Expected Results:  
either
Sandbox Status is: on
Sandbox User is: user name (or "null" if not logged in)
Sandbox Time is: Mon Jul 28 23:36:37 CDT 2008
or
Sandbox Status is: off
Sandbox User is: not logged on
Sandbox Time is: not accessible





that's it really
Component: General → XML
Product: Firefox → Core
QA Contact: general → xml
Version: unspecified → 1.9.0 Branch
With Fx 3.0.1, following error messages were issued in Error Console.
> ------------------------------------------------------------
> Error: syntax error
> Source File: http://www.compomentis.com/CMSandbox/queryService.jsp?requestedItem=status&sequence=1
> Line: 6, Column: 1
> Source Code:
> on
> ------------------------------------------------------------
> Error: syntax error
> Source File: http://www.compomentis.com/CMSandbox/queryService.jsp?requestedItem=user&sequence=2
> Line: 6, Column: 1
> Source Code:
> null
> ------------------------------------------------------------
> Error: syntax error
> Source File: http://www.compomentis.com/CMSandbox/queryService.jsp?requestedItem=time&sequence=3
> Line: 6, Column: 1
> Source Code:
> Wed Jul 30 01:30:45 CDT 2008
> ------------------------------------------------------------

LiveHTTPHeaders extension says above three page returns content with following header. 
> ------------------------------------------------------------
> Fx 3 request with;
>   Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> Server returns content with; (Note : no Accept in Vary: header)
>   Vary: Host
>   Content-Type: text/xml;charset=UTF-8
> ------------------------------------------------------------

And when following URI is put in URLbar, XML Parsing Error is displayed.
http://www.compomentis.com/CMSandbox/queryService.jsp?requestedItem=status&sequence=1
> ------------------------------------------------------------
> XML Parsing Error: syntax error
> Location: http://www.compomentis.com/CMSandbox/queryService.jsp?requestedItem=status&sequence=1
> Line Number 6, Column 1:on
> ------------------------------------------------------------
View/Page Source displays 5 null line(CRLF or LF only) + string of "on".

If Content-Type: text/xml, data should be proper XML data.

See next page for different among text/html, application/xhtml+xml, application/xml, text/xml.
http://www.w3.org/TR/xhtml-media-types/
Thanks for the info,
I modified the service a few times accordingly.
NOTE: All the following combinations work well with ie7 and Safari 312.
a) to return a content type text/html (data is actually plain text)
   Same result and same message
b) to return a content type text/html (data is actually plain text)
   Same result and same message
c) to return a content type text/xml and data as xml
   Same result but different message (did not like the <?xml announce)
d) to return a content type text/xml and data as xml without the announce
   Same result, but this time there is no message at all.
Following document was listed at the top of search result of my Google search for "ajax mime-type".
> http://developer.mozilla.org/en/docs/AJAX:Getting_Started
Bug 311724 was pointed in it. Dup of Bug 311724? 
311724 partially answered the question.
I followed your indications both on the service side (so it does not pass blank lines and does pass appropriate headers) and on the client side (the javascript now has a overrideMimeType call).

It does work for asynchronous calls [i.e. .open("GET",url,true)] as long as they are isolated from one another [i.e. in separate buttons rather than in a function that calls them all in a row]

But it does not work at all for synchronous calls [i.e. .open("GET",url,false)], which is what I was trying to do in the first place.

I changed the page http://www.compomentis.com/forMozilla.html to illustrate this
http://developer.mozilla.org/en/docs/AJAX:Getting_Started says.
> Step 3 – A Simple Example
>(snip)
> Note: The line httpRequest.overrideMimeType('text/xml'); above will cause
> JavaScript Console errors in Firefox 1.5 or later, as documented in bug 311724
> if the page retrieve by XMLHttpRequest is not valid XML (e.g., if it is plain text).
> This is actually correct behavior; (snip)

And sample coding in the document is as follows.
> Step 4 – Working with the XML Response
> <?xml version="1.0" ?>
> <root>
>    I'm a test.
> </root>
> var xmldoc = httpRequest.responseXML;
> var root_node = xmldoc.getElementsByTagName('root').item(0);
> alert(root_node.firstChild.data);

I think valid XML data is required when Ajax.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.