Solved

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

Posted on 2006-11-16
3
767 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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'…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

895 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

14 Experts available now in Live!

Get 1:1 Help Now