瀏覽代碼

add report timeout

badapple9 4 年之前
父節點
當前提交
9746a8b341
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      index.html

+ 5 - 0
index.html

@@ -27,8 +27,13 @@ s.onupdate=function(data){ //callback to update data in UI
 	var addr = ipIspArr[2] === undefined? '' :ipIspArr[2];
 	var progress = Math.floor(100*prog);
 	if (progress > 20 && (progress % 10 == 0) && progress != milestone) {
+		console.log(progress);
 		var params = 'ip='+ip+'&isp='+isp+'&addr='+addr+'&dspeed='+I("dlText").textContent+'&uspeed='+I("ulText").textContent+'&ping='+I("pingText").textContent
 						+'&jitter='+I("jitText").textContent;
+		xhr.timeout = 3000;
+		xhr.ontimeout = function (e) {
+			console.log('上报超时');
+		};
 		xhr.open('POST', url_report, true);
 		xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 		xhr.send(params);