SCRIPT 600:此操作的目标元素无效。 (仅限IE)

时间:2012-04-14 04:55:05

标签: javascript ajax internet-explorer

我正在制作ajax日历,它在Chrome,Safari和& Firefox像往常一样。但它不能在IE9或更低版本中运行。

我收到以下错误 SCRIPT 600:此操作的目标元素无效。

这是一个WP插件,但这是代码

function show_micro_ajax(response) {
    document.getElementById('wp-calendar').innerHTML = response;
}

function microAjax(url, cF) {
    this.bF = function(caller, object) {
        return function() {
            return caller.apply(object, new Array(object));
        }
    };
    this.sC = function(object) {
        if (this.r.readyState == 4) {
            this.cF(this.r.responseText);
        }
    };
    this.gR = function() {
        if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');
        else if (window.XMLHttpRequest) return new XMLHttpRequest();
        else return false;
    };
    if (arguments[2]) this.pb = arguments[2];
    else this.pb = "";
    this.cF = cF;
    this.url = url;
    this.r = this.gR();
    if (this.r) {
        this.r.onreadystatechange = this.bF(this.sC, this);
        if (this.pb != "") {
            this.r.open("POST", url, true);
            this.r.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
            this.r.setRequestHeader('Connection', 'close');
        } else {
            this.r.open("GET", url, true);
        }
        this.r.send(this.pb);
    }
}​

1 个答案:

答案 0 :(得分:0)

如果您不必支持IE6,请删除ActiveX行, 否则,反转你的测试:

   if (window.XMLHttpRequest) return new XMLHttpRequest();
   else if (window.ActiveXObject) return new ActiveXObject('Microsoft.XMLHTTP');
   else return false;

我不确定实例如何成为一个数组, 并且可能IE也没有,特别是如果sn ActiveX对象中的一个成员。

return caller.apply(object, new Array(object))
相关问题