Solved

Javascript Error: Reference to undefined variable: No such variable 'XMLHttpRequest'

Posted on 2006-11-16
3
761 Views
Last Modified: 2008-02-01
In Opera 7.23 I'm getting the following error on my Ajax code:

message: Reference to undefined variable: No such variable 'XMLHttpRequest'

My create XMLHttpRequest code:

function createRequestObject()
{
    var request_o; //declare the variable to hold the object.
    var browser = navigator.appName; //find the browser name
    if (browser == "Microsoft Internet Explorer")
       {
         /* Create the object using MSIE's method */
         request_o = new ActiveXObject("Microsoft.XMLHTTP");
       }
    else
       {
         /* Create the object using other browser's method */
         request_o = new XMLHttpRequest();
       }
    return request_o; //return the object
}

var http = createRequestObject();

Can anyone explain why I'm getting this JS error?
0
Comment
Question by:rfresh
  • 3
3 Comments
 
LVL 41

Accepted Solution

by:
HonorGod earned 125 total points
ID: 17956766
 var xmlHttp;

  //------------------------------------------------------------------
  // Name: createXMLHttpRequest()
  // Role: Create the XML Request Object used by the Ajax routines
  //------------------------------------------------------------------
  function createXMLHttpRequest() {
    if ( window.ActiveXObject ) {
      xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" );
    } else if ( window.XMLHttpRequest ) {
      xmlHttp = new XMLHttpRequest();
    }
  }
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 17956794
Your if test is failing...

if (browser == "Microsoft Internet Explorer")

0
 
LVL 41

Expert Comment

by:HonorGod
ID: 17961912
Thanks for the 'A'
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now