Link to home
Start Free TrialLog in
Avatar of rfresh
rfresh

asked on

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

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?
ASKER CERTIFIED SOLUTION
Avatar of HonorGod
HonorGod
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Your if test is failing...

if (browser == "Microsoft Internet Explorer")

Thanks for the 'A'