// Custom Cart Code for Database Quantity Update
$('.input-text').on('keydown ' , function(){
var tr_parent = $(this).closest("tr");
setTimeout(function () {
$(tr_parent).css('opacity', '0.3');
}, 4000);
var input_value = $(this).val();
var input_value_length = input_value.length;
var product_id_update = $("#product_id").attr('data');
if(input_value_length > 0 ) {
// Delay execution using setTimeout
setTimeout(function () {
$.ajax({
url: "includes/ajax_code.php",
data:{input_value:input_value, product_id_update : product_id_update},
type: "POST",
success:function(data) {
$(tr_parent).css('opacity', '0.9');
}
});
}, 5000);
}
});
In this code snippet, the opacity of an input element is set to 0.3 to indicate data transfer. However, a problem arises when trying to change the opacity to 0.9 after the AJAX request finishes.
Despite setting up a second setTimeout function in the success callback of AJAX, the input element remains at an opacity of 0.3 instead of transitioning to 0.9 as intended.