function sleep(d){ for(var t = Date.now();Date.now() - t <= d;); } mycars = new Array() newmycars = new Array() xxi=0 function initte() { var i =1; while (i<8) { mycars.push(i) i++ } } function runte() { if(mycars.length==0) { return; } xxi=mycars.pop(); console.log('mycars[xxi]='); console.log(xxi); sleep(3000); commitForECMA(callbackCA,'content.jsp?tableId=25&tableName=TABLE25&tableView=境内生产药品备案信息公示&Id='+xxi,null) } function callbackCA() { console.log("mycars[xxi] end"); console.log(xxi); console.log(request); if(request.readyState==4) // 重试 { if(request.status!=200) // 重试 { newmycars.push(xxi) } if(mycars.length==0) { sleep(3000); mycars=newmycars; newmycars = new Array(); } if(mycars.length>0) { runte(); } else { console.log('完成'); } } } initte(); runte(); commitForECMA(callbackCA,'content.jsp?tableId=25&tableName=TABLE25&tableView=境内生产药品备案信息公示&Id=9',null)