if( $.isArray(certTypeReq) ){
$.each(certTypeReq,function(key,certType){
$.ajax({
url: baseUrl+"/user/certificate/getlink",
type: 'GET',
data: { 'certType' : certType},
dataType : 'json',
cache: false,
async:false,
success: function(data) {
window.location.href = data.link;
}
});
});
}
这是我的代码,它在 Firefox 中工作正常,但在 Chrome 浏览器中不行。如果有人有解决方案请帮助我。
最佳答案
var i=1;
if( $.isArray(certTypeReq) ){
$(certTypeReq).each(function(key,certType){
setTimeout(function () {
$.ajax({
url: baseUrl+"/user/certificate/getlink",
type: 'POST',
data: { 'certType' : certType},
dataType : 'json',
success: function(data) {
window.location.href = data.link;
}
});
}, 3000*i);
i++;
});
}
在每次迭代中应用延迟并且它起作用了。
感谢大家的回复。
关于javascript - 如何循环调用ajax来下载pdf文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31922545/