Home > front end >  Cycle sends a request to download tread pit
Cycle sends a request to download tread pit

Time:02-07

Direct stick code:
The original code is written like this:
$. Each (rowsDatas, function (I, data) {

Var ID__=data. ID__. Substring (6);
ID__=ID__. Substring (0, ID__. Length - 7);
Window. The open (basepath + 'ExportFile/downloadUserExcel? F='+ + forminfo. ID & amp; & B='+ ID__, "love");

})
//going to directly use cycle request download, as a result, each loop background have response, but the front desk can only download a


//after watching online solutions, found many times cycle download browser there is a limit to the same request; After going to add delay solve
$. Each (rowsDatas, function (I, data) {
SetTimeout (function () {
Var ID__=data. ID__. Substring (6);
ID__=ID__. Substring (0, ID__. Length - 7);
Window. The open (basepath + 'ExportFile/downloadUserExcel? F='+ + forminfo. ID & amp; & B='+ ID__, "love");
}, 500);
})
//the time delay is still doesn't work
//see all kinds of stickers, on many pit after finally thought of solution
$. Each (rowsDatas, function (I, data) {
Var ID__=data. ID__. Substring (6);
ID__=ID__. Substring (0, ID__. Length - 7);

Try {
Var elemIF=document. The createElement method (" iframe ");

ElemIF. SRC=https://bbs.csdn.net/topics/basepath + 'ExportFile/downloadUserExcel? F='+ + forminfo. ID & amp; & B='+ ID__;

ElemIF. Style. The display="none";

Document. The body. The appendChild (elemIF);

} the catch (e) {
Alert (" download exception!" );
}
})
//address
//wish you hit the pit less, only supplies the reference

  • Related