Talk:XMLHttpRequest

From Wikipedia, the free encyclopedia

Contents

[edit] Known bugs

Can anyone provide any reference to show that the IE cache bug descirbed in the 'known bugs' is correct? I have never encountered this problem. --Sleepyhead 10:31, 20 August 2005 (UTC)

Neither have I, there is probably no bug. Taka 14:42, 29 October 2005 (UTC)

I remember having problems with opera caching get requests using this. I appeneded a unixtimestamp to avoid it though.

I've seen this problem with IE6. I think it only happens when you send requests from more than one Javascript function. For example, I'm using Ajax to update dropdowns. Setting one queries the database for values for the second. Setting the second dropdown queries the database for values for the third dropdown. But what might be helpful here is a better description of what non-idempotent operations are. DRogers 23:16, 4 October 2006 (UTC)

[edit] Rename to XMLHttpRequest

I suggest that this article is renamed to XMLHttpRequest which is the correct and complete term for the object used in the browsers. --Sleepyhead 12:22, 22 August 2005 (UTC)

Doesn't Mozilla use XMLHttpRequest? See Mozilla xmlextras, for example. Hmmm, actually that seems to be the preferred style: [1] [2] [3] Mindmatrix 13:18, 22 August 2005 (UTC)
Correct. I have updated my comment. I think XMLHTTP (Microsoft object) should be moved to XMLHttpRequest (opera/safari/mozilla/general style). XMLHTTPRequest should be redirected to XMLHttpRequest. --Sleepyhead 13:39, 22 August 2005 (UTC)
What happened to this discussion? I think there is no doubt now that this article should be 'moved' to XMLHttpRequest, (now a W3C Working Draft (05 April 2006)). The article should still mention the historical fact that MS originally implemented the API as an Active-X server called XMLHTTP in their MSXML dll, but once IE7 hits the streets, that will become more of a historical footnote. --Nigelj 19:03, 11 April 2006 (UTC)
I tried to move the page today, but it errored because the redirect at XMLHttpRequest has some history. I could have tried to do a three-way thing ending up with a page called XMLHttpRequest (Please delete me), but the error page told me to put a request on WP:RM and an Admin would sort it out. So that's what I've done. --Nigelj 10:31, 29 April 2006 (UTC)
Done. —Nightstallion (?) Seen this already? 07:48, 4 May 2006 (UTC)

[edit] Internet Explorer version

I've re-fixed this article to state that it was Internet Explorer 5.0 with the first support for XMLHttpRequest. While it's true that Internet Explorer 4.0 had support for an older version of MSXML, this older version of MSXML did not contain the XMLHttpRequest object. Please see the following link, where it is unambiguously stated that 5.0 was the first version with XMLHttpRequest support:

http://www.microsoft.com/mind/0999/webapp/webapp.asp

The supporting evidence for the 4.0 claim, as supplied by Sleepyhead81, doesn't mention XMLHttpRequest at all, merely MSXML:

http://support.microsoft.com/default.aspx?scid=kb;en-us;269238

Unless stronger evidence exists that 4.0 introduced this object, the article should continue to state that 5.0 was the first version with XMLHttpRequest support.

Update: further evidence that 5.0 is correct and 4.0 is incorrect. An Internet Explorer developer states this in his weblog:

http://blogs.msdn.com/dmassy/archive/2005/03/20/399412.aspx

[edit] setRequestHeader

Why is it stated that that IE does not support "setRequestHeader" ? It does support it, see a.o. http://support.microsoft.com/kb/893659.

req.open("POST", "xml.php");
try { // IE does not have this method
   req.setRequestHeader('Content-Type','text/xml');
} catch (error) {};
req.send('<xmldoc><tag val="test"/><value>test</value></xmldoc>');

Taka 13:53, 29 October 2005 (UTC)

Fixed. --minghong 00:21, 15 November 2005 (UTC)

[edit] Adobe's Flash Player

Actually, Adobe does own the Flash Player, having recently acquired Macromedia. Please don't change this entry, no matter how funny you think it is. Scott Arbeitman 12:20, 16 December 2005 (UTC)

Yes, Adobe has acquired Macromedia. But the name Macromedia Flash Player is still used on the adobe.com website. Also Flash is known as Macromedia Flash - not Adobe Flash. So choosing the latter name is a bit confusing. I think it should state Macromedia Flash Player - at least until Adobe change the name. --Sleepyhead 12:47, 16 December 2005 (UTC)
OK, agreed. I will change it back. --Scott Arbeitman 06:36, 17 December 2005 (UTC)

[edit] Isn't XmlHttp ActiveX?

Under other ways of achieving XmlHttp-like functionality, ActiveX is listed. However, XmlHttpRequest is implemented as an ActiveX technology in Internet Explorer. I definitely see the point of listing it, but as stated it isn't entirely accurate. --Scott Arbeitman 06:41, 17 December 2005 (UTC)

[edit] Browser specific issues

Some websites that are generated with MS Visual Studio use IE-specific settings and can not be viewed with other browsers. If there are are information about this issues, I thing including them will help. For example there's a IBM Developerworks tutorial about how to migrate from IE to Mozilla. [4] If someone has more information, please let me know.

[edit] Examples of applications that use XMLHTTP

There used to be a similar section to this on our Ajax article, and it was deleted as it attracted depressing amounts of link spam, for sites that used Ajax in even a trivial capacity. I have scaled the list on this XMLHTTP page down to the big names (Google maps, Suggest etc.), but I think the section could just as well be deleted outright. Rufous 16:54, 8 January 2006 (UTC)

It must be deleted: virtually any website will be an example of HTML, Ajax, CSS etc... There is nothing to learn, this is a reason to use them, but Wikipedia is not a tribune... Alcalazar 11:40, 13 April 2006 (UTC)

[edit] most well designed webpages use XHLHTTP????

Give me a break - most well designed webpages DON"T NEED anything other than HTML and CSS... --81.59.104.31

Most well-designed web pages using XMLHTTP are designed to hide the minor differences in these XMLHTTP object implementations
Er, read that sentence again. Rufous 21:30, 17 January 2006 (UTC)

[edit] Is the Known Problems section encyclopedic?

I have a feeling this would fit better someplace akin w3schools instead of an encyclopedia. --Qviri (talk) 17:16, 27 January 2006 (UTC)

It is very Wikipedia-encyclopedic. We have the finest collection of computer-related information articles to be found anywhere.
Now: I think we need to add something about MIME type problems. These creep up quite a bit, especially when working with Safari. Thoughts? 70.20.179.75 21:39, 29 January 2006 (UTC)
I don't mind information, and I love webdev personally, but this is a FAQ section, for crying out loud. --Qviri (talk) 00:39, 30 January 2006 (UTC)
If the Known Problems section is maintained, it might be good to also mention Mozilla's (and other's?) need for script signing when the script accesses external sites. -- Peter 10:44, 2 March 2006 (UTC)

Encyclopedia articles should be written for the general reader, and be descriptive, not instructional. But then, who is the "general reader" in a given context, and when does describing an issue become instruction?

In this case it does seem the line has been crossed though, by not only describing programming issues, but giving specific recommendations on how to fix them. Can you imagine an article on elephants in Africa that goes on to list specific steps that nature reserve managers should take to deal with an outbreak of some communicable animal disease? The existence of the disease, that steps are being implemented to deal with it, are descriptive. Specific instructions on how to apply a solution of iodine two times daily to the affected patches on the elephants' skin -- and you may find the elephants more cooperative after hay feeding time -- goes in a newsletter to the nature reserve managers, not an encyclopedia.

Nonetheless, this is great, useful informations (for the minority of readers actually using the technology rather than wondering what the acronym means).

Does Wikimedia yet have a "manuals" section? That's where it belongs. The encyclopedia article describes that there are a number of issues that affect implementation, and refers the reader to the "manuals" article.

If presently we lack this "manuals" section, a good approach would be to create two articles on this subject: a descriptive overview, written for someone generally familiar with Web development, who has no intention of actually writing the code, and a "technical details" article for programmers.

   XMLHTTP (Overview)
   XMLHTTP (Technical Details)

Cross-referenced, of course.


[edit] XMLHTTP in ASP?

This article concentrates on browsers, but XMLHTTP is available in ASP through Server.CreateObject("Microsoft.XMLHTTP"). I'm not sure if this is worth mentioning, and I am also not positive what the exact server requirements are to support it. Mpd 21:31, 20 April 2006 (UTC)

One solution to this is to use the POST request method, which is never cached; however, it is intended for non-idempotent operations.

[edit] Non-idempotence

Does anyone else feel that "non-idempotence" is irrelevant when the problem with GET is caching? If caching is causing problems, surely it could only be a non-idempotent operation that is being carried out?

Not necessarily. Suppose you GET weather forecasts for the next hour. Result "14:00-15:00 Sunny, slight cloud coverage. 5% precipitation chance.".
At 15:00 the server will change the message, to say "15:00-16:00 Sunny, some large clouds. 15% precipitation chance.". If the last message was cached locally, and didn't properly expire, then caching can cause a problem, even though it's idempotent.
Of course, in this case the server should send an expires header, but perhaps there are situations where client-side expiration is needed. Who knows. By the way, I'll remove the random-id thingy, as that would "snow" your cache, possibly making browsing a lot more harddisk intensive. Shinobu 03:41, 24 July 2006 (UTC)

[edit] Browsers, that do not yet have documentation from web-master perspective ?

Opera has offivial claim about support of XMLHTTPRequest, yet they do not offer the documentation (guess they are treating W3's draft as such? ) http://www.opera.com/docs/specs/opera9/index.dml - Desktops http://www.opera.com/pressreleases/en/2005/11/15/index.dml - mobile phones


KDE Konqueror shares much of code with Apple Safari and hence is supporting it too. KDE documents XMLHTTPRequest for C++ developers, but not for Web-masters (or i failed to find it). http://developer.kde.org/documentation/library/cvs-api/kdelibs-apidocs/khtml/html/xmlhttprequest_8h-source.html

Should those links be mentioned on the page in See Also section (guess not in Documentation, since they are not documentation for web-masters) ?

[edit] Opinions

"One of the best Javascript libs out there that enhances XMLHttpRequests is protoype.js"

Sounds like an opinion to me? I don't mean to say that prototype is not good (actually I have no idea), but Wikipedia is about facts not opinions.

Yes, there are now millions of "web 2.0" libs out there, Wikipedia shouldn't be passing judgements on which are the best. 209.92.136.131 15:04, 20 June 2006 (UTC)

[edit] document.implementation.createDocument()

Shouldn't the article mention this other way of bringing in data to the browser? Wikipedia doesn't seem to have any articles that mention document.implementation. 209.92.136.131 15:04, 20 June 2006 (UTC)

[edit] Handling of plain text and utf-8

I find this part confusing: "If the server answer does not encapsulate the result in an XML format, the 'responseText' may not work correctly when using non-ASCII characters, for example accented characters like é. Although Firefox copes with such data, Internet Explorer will only handle it properly for the first request (although there may be display problems). If the request is repeated and Internet Explorer uses a cached result, then it will generate a JavaScript error."

The formulation of this seems to come from somebody who has no idea about character encodings and HTTP headers. It also sounds like this is personal research. I would like to see a pointer to an external article that substantiates the issue above. I have tried to Google this and so far I have not found an article or blog entry reporting issues for example with JSON and IE when using utf-8. Of course if you don't send your text with something like: "Content-Type: text/plain; encoding=utf-8", nothing will work.

What I think the writer is trying to say is this: When you first open a textfile on a webserver, the request converts from the supplied encoding to UCS-2 (or UTF-16, but I don't know if it supports surrogates). But if the request gets the textfile from the cache, it converts from ANSI.
Whether it really does this, I don't know. Are character encodings saved with the textfiles in the cache? I don't know. I wonder if there's a way to find this out... Shinobu 11:05, 4 August 2006 (UTC)

I did find a reference to such an issue ... http://www.vbulletin.com/forum/bugs35.php?do=view&bugid=1836 ... see the stuff by Mike Sullivan? If true, however, this only affects IE 5.5 and earlier - all later versions shipped with newer MSXML. - MJB, Sept 23 2006

[edit] Reusing XMLHttpRequest In Netscape 8.1

I find that if I reuse the request object in Netscape 8.1, the second request arrives at the server, but the response does not get back to the client. The readyState property stays at 1 ("loading"). This happens even if I call abort() in state 4 of the first request. If I always create a new XMLHttpRequest object, all works fine. So, how come all the Web references to this reusability problem just discuss the IE requirement of doing the open and onreadystatechange operations in that order, and none mention a problem with Netscape? David 19:35, 8 September 2006 (UTC)

[edit] Synchronous calls in Mozilla

I have removed the section about the onreadystate event not working with synchronous calls in Mozilla. Mainly, using the event in synchronous mode is utterly pointless, since the whole purpose of synchronous calling is to block the code and hence it does not require an event handler. Also, the example code was messy and would not have worked.

I didn't notice at the time, but my edit is credited to 121.44.46.109 as I forgot to log in.

- Penagate 09:20, 29 September 2006 (UTC)

[edit] Methods & properties

Wikipedia is not a programming reference guide, so we need to replace the terse tables of methods and properties with prose descriptions of what the interface does. --P3d0 12:27, 1 October 2006 (UTC)

So would code examples be out of the question? Or are code examples better suited to external links? DRogers 12:56, 4 October 2006 (UTC)
Good question... I’m not sure anymore. Maybe I should say we should have prose descriptions before we dive into the API and examples? --P3d0 17:59, 6 October 2006 (UTC)

[edit] Thank you for the information about IE caching!

I have been struggling with that and unable to find the right combination of parameters to avoid the caching. The clear explanation here of what to add to the xhr request is wonderful, and it works!

--Julian