JSFiddle - React, Tailwind, and code Playground
JavaScript
$.ajax({
async: false,
dataType: "json",
url: urlTicket,
cache: true,
beforeSend: function(){
$.blockUI({ message: '<h1><img src="images/busy.gif" /> Veuillez patienter SVP...</h1>' });
$(document).ajaxStop($.unblockUI);
},
success: function(data){
if (data!=null){
var items = [];
var line = '<tr id=row'+elements[i]+'>';
$.each(data, function(key, val) {
var t;
if ( isNaN(val) ){
t = wordwrap(val, 45, '<br/>');
} else {
t = val;
if ( key == "pxvente" ){
sum += t;
t += "€";
}
}
if ( key == "pxvente" ){
line += '<td id=prix>'+t+'</td>';
} else {
line += '<td>'+t+'</td>';
}
});
line += '</tr>';
// insert at an index :
// $('#my_table > tbody > tr').eq(i-1).after(line);
$('#ticketTable > tbody:last').append(line);
$("#total").html("Prix total : "+sum+" €");
}
}
});