【发布时间】:2019-04-18 16:40:28
【问题描述】:
我有很多请求 ajax,所有这些都结束了,显示消息:“承诺结束”,但我想在“处理”或“工作......”时显示消息,我不知道。我用jquery
$("#btnDelete").click(function () {
var promises = [];
if (confirm("¿Seguro que quiere borrar?")) {
$('.delete:checked').each(function (index, value) {
promesas.push(
$.ajax({
method: "POST",
url: "transaccion.php",
data: {
id_pagos_detalle: $(this).val(),
accion: "Registrar_inf_consignacion",
estado_elemento: "Si"
}
}).then(function (msg) {
if(msg.indexOf("SUCCESS") != -1){
console.log("delete this element");
}else{
alert("ERROR");
return false;
}
})
); // end promise
});
// process all promises
$.when.apply($, promises).then(function(){
alert("Promises ended");
location.reload(true);
});
}
});
【问题讨论】:
-
在
$('.delete:checked').each之前显示“工作”消息 - 但不要使用alert- 因为那会阻塞
标签: javascript jquery ajax promise