I want to ask you here. I have an array of objects like this on this array of objects. I want to use it as a data post to the controller when I run it. There's an error. Error CSRF missmatch.
my code
var dataarray=[];
dataarray.push({
_token:$('#_token').val(),
no_draft :$('#no_draft').val(),
no_transaction :$('#no_transaction').val(),
currency :$('#currency').val(),
kurs_total_idr :$('#kurs_total_idr').val(),
no_referensi :$('#no_referensi').val(),
grant_total_ap :$('#grand_total_ap').val(),
payment_type :$('#payment_type').val(),
grant_total_payment :$('#grand_total_payment').val(),
payment_account :$('#payment_account').val(),
payment_account_id :$('#payment_account_id').val(),
note :$('#note').val(),
date :$('#datepicker1').val(),
grant_total_payment :$('#grand_total_payment').val(),
status :$('#status').val(),
acc_tra_ap_payment_detail:acc_tra_ap_payment_detail,
});
var url = "";
savemethod="add"
if (savemethod === 'add') {
url = "<?php echo url('ap-payment/store') ?>";
} else {
url = "<?php echo url('/updatepegawai') ?>";
}
$.ajax({
url: url,
contentType: 'application/json',
type: "POST",
data: dataarray,
dataType: "JSON",
success: function (data) {
console.log("berhasil",data);
},
error: function (request, status, error) {
alert("Error json " + error);
}
});