Can not pass list of object to method by AJAX
Try to put data into formData
one by one:
function PayAjax(orders, payment, note) {
orders = [{ 'id': 1, 'quantity': 2 }, { 'id': 3, 'quantity': 4 }];
var formData = new FormData();
for (var i = 0; i < orders.length; i++) {
formData.append("orders[" + i + "].Id", orders[i].id);
formData.append("orders[" + i + "].Quantity", orders[i].quantity);
}
formData.append('payment', payment);
formData.append('note', note);
$.ajax({
dataType: 'json',
url: '/sale/pay',
type: 'POST',
data: formData,
processData: false,
contentType: false,
success: function (result) {
var x = 1;
},
error: function (error) {
console.log(error);
}
});
}