continuous problem with repeated serial numbers Serial number remains the same after each click
$(document).on('click', '.menu-item', function() {
var menu_id = $(this).attr('id');
var _token = $('input[name="_token"]').val();
console.log(menu_id);
var i = 1;
$.ajax({
url: '{{ url("waiter/menu/find") }}',
method: 'POST',
data: {menu_id:menu_id, _token:_token},
dataType:"json",
success: function(data) {
$('#selectedMenu').append('<tr><td>' + i++ +'</td><td>' + data.name + '</td><td><input type="number" name="quantity[]"></td><td>' + data.price + '</td><td><span class="btn btn-xs btn-danger"><i class="cancel fa fa-times"></i></span></td></tr>');
}
});
});
[How to update i++ for table serial number after each click]