I am trying to pass two js array to jquery ajax to a php backend. However in the network tab, in the dev tools I receive > Failed to load response data. Any suggestions TY
var arr1 = [];
var arr2 = [];
var id = 2432;
$.ajax({
type: "POST",
url: '/api/put/update_dealer_manufacturer.php',
async: true,
data: {arr1, arr2, id},
dataType: 'json',
success: function(data) {
let output = data;
},
error: function(data) {
console.log("error");
console.log(data);
}
});
In the backend I am doing:
$output = array(
"success" => false,
"msg" => ''
);
$arr1 = $_REQUEST['arr1'];
$arr2 = $_REQUEST['arr2'];
$id = $_REQUEST['id'];
On the back end I have
<?php
if(empty($_REQUEST['id'])){
$output['msg'] = "Authentication error";
echo json_encode($output);
die();
}
$new_manufacture = $_REQUEST['arr1'];
$delete = $_REQUEST['arr2'];
$id = addslashes($_REQUEST['id']);
I loop then with a foreach on each arr.
At the end of the backend file I do but for some reason I
do not get any results as way to tell if I reached the backend file.
$output['success'] = true;
echo json_encode($output);