I have a question about ajax. I have a project made in Laravel 7 that performs the functionality of adding products and increasing the quantity, and it has already been done. To avoid refreshing the browser, I did it through ajax and it works. I show my code
<script type="text/javascript">
$(document).ready(function(){
$(".btn-update-quantity").on('blur', function(e){
var id = $(this).data('id');
var href = '/admin/updateservicios';
var cantidad = $("#quantity_"+ id).val();
$.ajax({
url: href + "/" + id + "/" + quantity,
data: { 'id' : id, 'quantity':quantity },
type: "GET",
cache: false,
success: function() {
$("#table_refresh").load(href);
//$("#table_refresh").load(" #table_refresh");
}
});
});
});
</script>
What I do is by means of an input
<input type="number" name="quantity" class="btn-update-quantity form-control" value="{{$part['quantity']}}" id="quantity_{{$servs_id}}" data-id="{{$servis_id}}">
every time an amount is entered, it is updated, but the problem starts when I send the first ajax request and if it changes the value and refreshes the div, but when I make another change in the amount, it no longer works. How could I do to send an ajax request again without refreshing the browser since it lost the functionality