window.XMLHttpRequest is undefined in IE7/IE8

前端 未结 3 1037
粉色の甜心
粉色の甜心 2020-12-18 11:21

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

3条回答
  •  遥遥无期
    2020-12-18 11:57

    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.

提交回复
热议问题