getXMLHttpRequest httppost 超时没有反应。

creator 209版本
代码如下:
原生环境超时后,ontimeout 没有回调。

/** * 不需要跨域访问的post接口 */HttpHelper.postNew = function(url, data, callback) { var xhr = cc.loader.getXMLHttpRequest(); cc.log("[HttpHelper.postNew] url = ", url + " data = " + data); xhr.onreadystatechange = function() { cc.log(‘xhr.readyState=’+xhr.readyState+’ xhr.status=’+xhr.status); if (xhr.readyState == 4 && (xhr.status >= 200 && xhr.status <= 207)) { callback(true, xhr.responseText); }else{ // cc.log("HttpHelper.postNew xhr.readyState == ", xhr.readyState + “xhr.status”, xhr.status); // callback(false, “”); } };
xhr.open(“POST”, url, true);
xhr.ontimeout = function () { cc.log(’[HttpHelper.postNew]:Timeout’); callback(false, “”); };
xhr.timeout = 2000; xhr.send(data);};

上传中…

代码格式有问题,贴图如上。