FAQ 4.34 note about XMLHttpRequest in NN6.2+

P

Peter Michaux

Hi,

The FAQ correctly says the following:

"Mozilla (NN6.2+, Firefox, Ice Weasle etc), Opera 7.6+, Safari1.2+, the
Windows version of IE versions 5+, and some other browsers provide the
XML HTTP Request object."

In my haze of testing yesterday it seems that NN6.1 provides an
non-functional XMLHttpRequest object and NN6.2 XMLHttpRequest object
can only make GET requests as it's xhr.send() function errors if sent
arguments.

Perhaps the FAQ should be updated to reflect this information? I can
pin down the details if there is interest.

Peter
 
R

Randy Webb

Peter Michaux said the following on 1/13/2007 3:25 PM:
Hi,

The FAQ correctly says the following:

"Mozilla (NN6.2+, Firefox, Ice Weasle etc), Opera 7.6+, Safari1.2+, the
Windows version of IE versions 5+, and some other browsers provide the
XML HTTP Request object."

In my haze of testing yesterday it seems that NN6.1 provides an
non-functional XMLHttpRequest object and NN6.2 XMLHttpRequest object
can only make GET requests as it's xhr.send() function errors if sent
arguments.

Perhaps the FAQ should be updated to reflect this information? I can
pin down the details if there is interest.

Probably the best place for information like that would be a page that
shows where XMLHttpRequest works as desired and where it doesn't. A page
similar to my script page with a list of browsers and whether it works
or not. If you can post a list of browsers and any problems or failures
with XMLHttpRequest then I can add it to my current page or make a new
one and add it as a Notes page to the FAQ. As for a quick answer, I
think the current answer is fine. Trying to go into too much detail in
the FAQ itself lends itself to making the FAQ too large and it is
already getting huge.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
 
P

Peter Michaux

Hi Randy,

Randy said:
Peter Michaux said the following on 1/13/2007 3:25 PM:


Probably the best place for information like that would be a page that
shows where XMLHttpRequest works as desired and where it doesn't. A page
similar to my script page with a list of browsers and whether it works
or not. If you can post a list of browsers and any problems or failures
with XMLHttpRequest then I can add it to my current page or make a new
one and add it as a Notes page to the FAQ.

Is there a page about your script insertion and dynamic script loading
on the jibbering site now?

I found many bugs and notable features in early and not so early
XMLHttpRequest implmentations. I'll make a list.

Peter
 
R

Randy Webb

Peter Michaux said the following on 1/18/2007 4:16 PM:
Hi Randy,

Hi.

Is there a page about your script insertion and dynamic script loading
on the jibbering site now?

No. Although it would be trivial to upload it and the associated files.
Make it a Notes page (which would require a lot more explanation than
what is on the page now) and then link to it from the FAQ somehow somewhere.
I found many bugs and notable features in early and not so early
XMLHttpRequest implmentations. I'll make a list.

Post them with the UA, OS and any troubles and I can add it to my page,
then when I have time I can write a Notes article for review to post on
the jibbering server.
 
P

Peter Michaux

Randy said:
Peter Michaux said the following on 1/18/2007 4:16 PM:


Post them with the UA, OS and any troubles and I can add it to my page,
then when I have time I can write a Notes article for review to post on
the jibbering server.


Below is a set of notes I gathered about 14! potential XHR hiccups for
beginners. Before posting this information on the jibbering site I
would make the effort to double check all the browser versions and
other details. I could also add a test case that shows the error and a
workaround for each.

If anyone knows another XHR bug please post it and I can look into it
also for inclusion.

Peter

-------------

Internet Explorer < 7

Must use ActiveXObject() constructor function to create an
XMLHttpRequest object. And must try different ways

new ActiveXObject("Msxml2.XMLHTTP.3.0");
new ActiveXObject("Msxml2.XMLHTTP");
new ActiveXObject("Microsoft.XMLHTTP");



Internet Explorer 6
Windows XP SP2

When the server response stored in xhr.responseText is very big
Internet Explorer noticably leaks memory. The solution is after the
code is finished with xhr either set xhr.onreadystatechange to an empty
function with a clean closure or to set xhr to null.

<URL:
http://groups.google.com/group/comp.lang.javascript/msg/556048483801bd96>



Netscape Navigator 6.1
Windows XP SP2

This is the first Netscape browser with the XMLHttpRequest()
constructor function. However it returns an object that is non
functional.



Netscape Navigator 6.2, 6.2.3
Windows XP SP2

The XMLHttpRequest objects are capable of GET and POST requests but the
xhr.send() function cannot be sent any argument other than null. If you
attempt to send a body as the argument to send the browser throws an
error.



Netscape Navigator 7.0 & 7.1
Windows XP SP2

When the server response stored in xhr.responseText is very big these
two versions of Navigator noticably leak memory. The known fixes for
the Internet Explorer memory leaks do not stop these problems.



Netscape Navigator 7.0
Windows XP SP2

If you want to set the "Accept" header of your XMLHttpRequest object
before sending the request to the server you are not getting a blank
canvas. When the XMLHttpRequest object is created it already has a
value for the Accept header. If you call

xhr.setRequestHeader("Accept", "text/javascript");

then this will not overwrite the original Accept header. Instead the
original header will have a comma and space appended followed byt the
new header.



Netscape Navigator <=7.1 && Firefox <=1.5
Windows XP SP2

Cannot make POST requests to URLs starting with localhost or to local
IP addresses. To test in these browsers the site must be live somewhere
out there on the web.



Firefox 1.5
When abort() is called a readystate 4 event is fired which is a
disaster. The "aborted" flag is a workaround to avoid having callbacks
fired when a request is aborted.

The Quirksmode website says that IE has this same bug and given the
date of writing it likely refers to IE 6.
http://www.quirksmode.org/blog/archives/2005/09/xmlhttp_notes_a_1.html



Opera 8.0

Opera 8 XMLHttpRequest objects don't have the setRequestHeader()
function and although the browser seems to be able to make a POST
request with a body without this function (and so without the usual
Content-Type = "application/x-www-form-urlencoded"). Note Opera 8.0.1
does have setRequestHeader() and can POST



Opera 8.51-8.53
Windows XP SP2
If the server response Content-Type header is "text/plain" or
"text/html" then all seems well. If it is "text/javascript" then the
xhr.responseText is garbled. It looks like a bunch of little squares
when printed. To feature test requires a test request sent to the
server and the response analysed. Probably not what you want to do
except in the most critical app on earth.



Opera 8.01, 9.10
Windows XP SP2

If the server sends a large response Opera's CPU useage rails at 100%
for a long time. Theses browsers are *very* slow to accept the
response.



iCab 3.0.3
Mac OS X 10.4.8
xhr.getResponseHeader() always returns an empty string however
xhr.getAllResponseHeaders() works. Here is a possible work around to
check if the Content-Type header is text/javascript or
application/javascript.

xhr.getResponseHeader("Content-Type").match(/(text|application)\/javascript/)
||
xhr.getAllResponseHeaders().match(/Content-Type\:\s(text|application)\/javascript/);



General Hearsay

Rumor has it that at least one browser caches GET requests made with an
XMLHttpRequest object. To avoid using any cached response add a unique
dummy id parameter as a query string to the URL to make it different
than all previous URLs and hence insure the specific new request has
never been cached.


Rumor has it that sometimes Firefox/Mozilla will throw an error when
accessing xhr.status and the Yahoo! UI library was the place I saw this.
 
A

adamraney

I ran into an issue that should perhaps be added to the list of XHR
issues.

I had an application that was sending very large server responses back
to the client. Regardless of header settings regarding caching etc, in
Firefox the memory usage was increasing with each response, even though
I was discarding the information.

After a lot of hair pulling, I discovered that the issue was with the
Firebug extension for Firefox. It has a setting to keep track of all
XHR transactions and was storing the large response for each and every
one. Once I disabled Firebug, the issue vanished.

Since Firebug is growing in popularity as a Javascript Debugger, it may
be worth noting this for anyone who doesn't realize the danger.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top