I have a scenario that the customer decide on number of tickets to be printed, am using printjs
and it is working perfect with one time print ,but in a loop to print multi,it only print last one ??? a
any one knows why ??
// 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");
});
}
Edit : just a not i do not use the index (i) any where inside the the loop ,i call another function , so it is not an index issue ,