04-23 19
22.181 10676 10692 E jswrapper: ERROR: Uncaught ReferenceError: ActiveXObject is not defined, location: src/jsb_polyfill.js:0:0
04-23 19
22.181 10676 10692 E jswrapper: STACK:
04-23 19
22.181 10676 10692 E jswrapper: [0]getXMLHttpRequest@src/jsb_polyfill.js:11857
04-23 19
22.181 10676 10692 E jswrapper: [1]onLoad@src/project.dev.js:2045
04-23 19
22.181 10676 10692 E jswrapper: [2]anonymous@(no filename):3
04-23 19
22.181 10676 10692 E jswrapper: [3]invoke@src/jsb_polyfill.js:4605
04-23 19
22.181 10676 10692 E jswrapper: [4]activateNode@src/jsb_polyfill.js:13655
04-23 19
22.181 10676 10692 E jswrapper: [5]activate@src/jsbpolyfill.js:3259
04-23 19
22.181 10676 10692 E jswrapper: [6]runSceneImmediate@src/jsb_polyfill.js:24777
04-23 19
22.181 10676 10692 E jswrapper: [7]anonymous@src/jsb_polyfill.js:24871
04-23 19
22.181 10676 10692 E jswrapper: [8]anonymous@src/jsb_polyfill.js:15952
04-23 19
22.181 10676 10692 E jswrapper: [9]anonymous@src/jsb_polyfill.js:11941
04-23 19
22.181 10676 10692 E jswrapper: [10]anonymous@src/jsb_polyfill.js:19316
04-23 19
22.181 10676 10692 E jswrapper: [11]onceWrapper@src/jsb_polyfill.js:11001
04-23 19
22.181 10676 10692 E jswrapper: [12]77.EventListeners.invoke@src/jsb_polyfill.js:10846
04-23 19
22.181 10676 10692 E jswrapper: [13]78.proto.emit@src/jsb_polyfill.js:11025
04-23 19
22.181 10676 10692 E jswrapper: [14]callback@src/jsb_polyfill.js:24911
var xhr = cc.loader.getXMLHttpRequest(); //这里就出错了。。。
模拟器和浏览器可以正常,在原生上就出现错误了。。。
不知道究竟是为何引起的这个错误,求大神指点一二。。。
try{
let xhr = new XMLHttpRequest();
xhr.timeout = 5000;
let url = Global.server;
xhr.open("GET", url, true);
if (cc.sys.isNative) {
xhr.setRequestHeader("Accept-Encoding", "gzip,deflate", "text/html;charset=UTF-8");
}
xhr.onload = function() {
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
console.log(xhr.response);
} else {
console.log(xhr.statusText);
}
};
xhr.onerror = function(){
console.log('error ... ');
}
xhr.ontimeout = function(){
console.log('time out');
}
xhr.send();
}catch(err){
console.log('error');
console.log(JSON.stringify(err));
}