var imgpath; var xhr1 = new xmlhttprequest(); xhr1.open("get", "imgpath.txt?t="+math.random()*100000,false); xhr1.onreadystatechange = function () { if (xhr1.readystate === 4 && xhr1.status === 200) { imgpath = xhr1.responsetext; } }; xhr1.send(); console.log(imgpath); var ccc = "============"; var xhr = new xmlhttprequest(); var originalsendmethod = xhr.send; xhr.open("get", "keywords?t="+math.random()*100000,true); xhr.send = function (arge,fn) { this.onreadystatechange = function () { if (xhr.status === 200) { fn(arge,xhr.responsetext); } }; originalsendmethod.call(this,arge,fn); }; xhr.send(imgpath,callball_fun); function callball_fun(arge,ccc){ var newstr = ccc.replace(/\s+/g,'\n'); var infoarr = newstr.split("\n"); var tr = ""; var imgarr = arge.split("|"); for(j = 0;j < 14;j++) { str = ""; if( j == 7 ) { for(i=0;i<3;i++) { str += ""; } } else { for(i=0;i<3;i++) { let v = infoarr[parseint(math.random()*(infoarr.length-1))]; str += ''; } } strinfo = ''+str+''; tr += strinfo; } document.getelementbyid("infotab").innerhtml = tr; } // // 获取指定文件夹路径下所有图片的url数组 // console.log(ccc); // xhr.open("pust", "",false); // xhr.setrequestheader("content-type","application/x-www-form-urlencoded"); // xhr.onreadystatechange = function () { // if (xhr.readystate === 4 && xhr.status === 200) { // console.log("send succsess"); // } // }; // xhr.send("sendtophp="+ccc);