Creating the XMLHTTPRequest Object

By Phil Ballard on Jun 23, 2006

General

Many browsers allow the XMLHTTPRequest object to be created directly. One method is to use this snippet. It tries all methods of creating the object until it discovers one that works.

Notes

  • Created by: Phil Ballard
  • Web Site: http://www.crackajax.net/

Microsoft’s Internet Explorer uses ActiveX to create the XMLHTTPRequest object, whereas other borwsers — notable the Mozilla/Firefox range — allow the object to be created directly.

There are several ways of tackling this issue, some using browser detection routines (or tools such as BrowserHawk), others taking an approach similar to the following code, which tries all methods of creating the object until it discovers one that works.

See also the basic description of the XMLHTTPRequest object here and a more detailed discussion here.

Source Code

Paste this source code into the designated areas.

Snippet

Paste this code into your script.


Comments

Blog comments powered by Disqus