Hi everyone, I have an issue when I download manifest file from remote server using cc.loader.getXMLHttpRequest() on Android, but work well on IOS. The function onreadystatechange is not call and onerror function too, so I don’t know what is wrong. Thanks.
Cocos2d-JS v3.17
This is my code
try {
cc.log("call getDataFromUrl:" + url);
var xhr = cc.loader.getXMLHttpRequest();
xhr.open("GET", url, true);
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && (xhr.status >= 200 && xhr.status < 300)) {
cc.log("**** call callback);
cb && cb(xhr.responseText);
}else{
cc.log("*** read url: " + url + ", xhr.readyState: " + xhr.readyState + ", xhr.status: " + xhr.status);
}
};
xhr.onerror = function () {
cc.log("****** xhr request url error");
cb && cb(null);
}
xhr.send();
} catch (exception) {
cc.log("******* request url error");
cb && cb(null);
}
Console output
call getDataFromUrl:http://192.168.5.106:8000/manifest/project.manifest