Review the following jQuery .on() method making an ajax call:
$('tbody').on('click', 'button',function() {
var updInfo = {};
updInfo.unqid = $(this).closest('tr').attr('unqid');
$.ajax({
url: "http://localhost/ReceptionVisitorKiosk/basecoat/server/checkout.php",
data: updInfo,
type: 'POST',
dataType: 'json',
}).done(function(data) {
$(this).closest('tr').removeClass('active-visitor').addClass('inactive-visitor');
$(this).addClass('glyphicon glyphicon-ok');
console.log(data);
}).fail(function(status,errorThrown){
console.log(errorThrown);
}).always(function(xhr,status){
console.log("The request 2 is complete");
}); // End AJAX call
});
When the user clicks the button the php script is called and updates the database. However, we should expect .done() to then remove and add the classes to $(this)
. I can't see that happening in the browser or f12 > inspector view
Upon a full page refresh, the class change is visible.