views:

229

answers:

3

Hi,

Value of window.XMLHttpRequest is Undefined when i run my application even in IE7 or IE8, Is there anything i have to enable in IE7 to make it work.

Thanks

+4  A: 

You can do something like this:

if (!window.XMLHttpRequest) {
  window.XMLHttpRequest = function() {
    return new ActiveXObject(”Microsoft.XMLHTTP”);
  };
}

I recommend looking at an AJAX library though, life is much easier in jQuery, ExtJS, MooTools, whatever you prefer.

Nick Craver
window.XNLHttpRequest is undefined in my case if i use the code if(!window.XMLHttpRequest) would give me an error.
Arvind
@Arvind - Did you try it? It works fine: `!(undefined thing)` == true in javascript.
Nick Craver
A: 

@Nick, your original answer had the ! inside the parentheses. that's why it didn't work for Arvind via cut/paste.

Greg
A: 

I enabled the native XMLHTTP support from internet options, after this the my code started working fine.

Arvind