我有一个场景,客户决定要打印的票数,正在使用printjs
,它与一次打印完美结合,但在循环打印多张时,它只打印最后一张???一个
任何人都知道为什么?
// loop to create and print ticket
for (var i = 0; i < TicketCount; i++) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "xxxxxxxxxxx",
data: TicketCategory,
dataType: "json",
success: function(data) {
// fill in the div with data
$("label[for =lblTicketAmount]").text(data.price);
$("label[for=lblTicketType]").text(data.ticketCategoryName);
$("label[for =lblDate]").text(moment().format('D MMM, YYYY'));
$("label[for =lblTime]").text(moment().format('HH:mm'));
$("label[for =lblUser]").text(data.userData);
$("label[for =lblSerial]").text(data.id);
$("label[for =lblTicketTaxes]").text(data.taxes);
printJS('dvshowdata', 'html');
},
error: function(jqXHR, textStatus, errorThrown) {
console.log('in error');
//alert("error : " + jqXHR.responseText);
}
}).done(function() {
$("#progress").dialog("close");
});
}
编辑:不是我不使用索引(i)循环内的任何地方,我调用另一个函数,所以这不是索引问题,