onreadystatechange中的评估无效

时间:2019-04-06 20:17:15

标签: javascript eval

我有一个http请求:

var System = {
    startApp:function(package) {
        var xhttp = new XMLHttpRequest();
        xhttp.open("GET","/@APP:/" + package + "/manifest.xml");
        xhttp.send();
        xhttp.onreadystatechange = function() {
            if (this.readyState == 4 && this.status == 200) {
                eval("(" + package + ".onCreate())"); //THE ERROR IS HERE
            }
        };
    };
};

但是当我打电话时:

var a = new System.startApp("b.c");
var b;
b.c.onCreate = function() {
    document.writeln("function called!!");
};

它不起作用,并且我正在Android的Chrome Canary中运行代码,因此我没有控制台提示,因为我没有桌面。

0 个答案:

没有答案