说明:Ajax for循环

Ajax isn't working on a for loop. Can someone correct my code and please explain it to me. 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.

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 found out that the reason why my code above isnt working because ecost: array6.eq(i).val doesnt have a () after the .val and also I found out that this is not a good practice that having a ajax calls on loops. Im sorry if I can't explain well here in stackoverflow that resulting on downvotes and having a temporary ban. But well I deserve it. I just can't improve my questions.