Can someone exlplain to me how ajax can be work on a for loop : I am stressed and desperate if how ajax isn't working on a for loop.
Can someone correct my code and please explain it to me. I am willing to learn more. But it keeps getting down whenever I cant get

    var counter = $("input[name^= 'quantity']").length;
            var array1 = $("input[name^= 'quantity']");
            var array2 = $("input[name^= 'unit']");
            var array3 = $("input[name^= 'item_description']");
            var array4 = $("input[name^= 'stock_no']");
            var array5 = $("input[name^= 'eunitcost']");
            var array6 = $("input[name^= 'ecost']");
            var i;
            for(i=0;i<counter;i++){
                $.ajax({
                    url: 'http://localhost/pm/admin/service/user-service.php',
                    type: 'POST',
                    dataType: 'json',
                    data: {
                        operation: 'pr-items',
                        pr_no: $('#prno').val(),
                        quantity: array1.eq(i).val(),
                        unit: array2.eq(i).val(),
                        item_description: array3.eq(i).val(),
                        stock_no: array4.eq(i).val(),
                        eunitcost: array5.eq(i).val(),
                        ecost: array6.eq(i).val
                        
                    },
                    
                    success: function(data) {
                        alert('pr items success');
                        //todo
                    },
                    error: function(data){
                       // alert('pr items error');
                        //todo
                    }
                });   
            }

I just want to put those value on my database. I can only make it work if i call ajax once not like this, it is in a for loop