Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8446707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:59:36+00:00 2026-06-10T09:59:36+00:00

For years I am using the same code snippet to create the XMLHttpRequest object:

  • 0

For years I am using the same code snippet to create the XMLHttpRequest object:

var tReq = (function () {
    var tAn;
    if (window.XMLHttpRequest) {
        tAn = new XMLHttpRequest();
    } else if (window.ActiveXObject) try {
        tAn = new ActiveXObject("MSXML2.XMLHTTP");
    } catch (ex) {
        tAn = new ActiveXObject("Microsoft.XMLHTTP");
    }
    return tAn;
}());

I have been using that code for so long that I do not know if it is still up to date.

Does this code still create the XMLHttpRequest in every browser or is there a more efficient solution nowadays (not asking for jQuery)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T09:59:38+00:00Added an answer on June 10, 2026 at 9:59 am

    I remember using this code, some four, five years ago? When the technique first got developed and was still being argued about (anyone remember the don’t disable the back button argument?), it was still somewhat patchily supported; this would be around Firefox 1/2. If I recall, this originated as an MS Outlook library that was used to make the Outlook client more responsive, and eventually the technique bled over into browsers.

    Having said that, the last two lines are legacy; all modern browsers have and do support the plain XMLHttpRequest, and the last two were only meant for IE anyhow. In the future, this will perhaps be shortened to HTTP or AsyncRequest or whatever, but the fact is, unless you need to support IE6, you really only need the first line.

    To wit:

    To support versions of Windows Internet Explorer prior to Internet
    Explorer 7, use the following function to get the XMLHttpRequest
    object.

    function getXMLHttpRequest()  {
        if (window.XMLHttpRequest) {
            return new window.XMLHttpRequest;
        }
        else {
            try {
                return new ActiveXObject("MSXML2.XMLHTTP.3.0");
            }
            catch(ex) {
                return null;
            }
        }
    }
    

    http://msdn.microsoft.com/en-us/library/ie/ms535874%28v=vs.85%29.aspx

    So, you don’t really need it anymore. As Truth says, libraries like jQuery, Angular and their ilk will subsume this into the background over time. But accessing it directly is not a problem either.

    Also worth linking to MSDN’s About Native XMLHTTP, courtesy of RobW’s comment under the question. The gist of this is that Group Policy or individual IE policy may disable native XMLHttpRequest, so it may still be useful to enable ActiveX as a workaround, although (at least at this point) it seems a little crayon tinfoil to disable that while allowing the much more “problematic” ActiveX subsystem. A possible explanation of this is bandwidth, concurrent connections or some other network-level concern. Weird.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: I recently completed a tic-tac-toe game in AS3, using some simple function-based code
I've been doing object-oriented programming for most of the past 7 years, using Java
I am using CodeIgniter Active Record Class to generat tables, my code snippet below.
I've been using the following bit of code for years to consume characters from
I have been tracking emails for years using a "beacon" image and for those
After about 10 years of using managed memory and functional languages, I'm finally coming
In the past few years of using svn, I've frequently run into problems where
We have an ADP project created several years ago using Access 2000. This project
Despite using PHP for years, I've never really learnt how to use expressions to
after using own custom cms for over 6 years, I decided to go for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.