i tried here a lot of options to send data from jQuery to php but without success, i'm trying to send an array of objects like here:
$.ajax({
type: "POST",
contentType: 'application/json',
url: "sendCartDetails.php",
data: {
'details': prod
}
});
where prod has this structure:
prod: [{name: 'Some Name'}, {name: 'Other Name'}]
and my php file:
$data = json_decode($_POST['details']);
$to = "email@email.com";
$subject = "New Order";
$headers = "From: Some ";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$message .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
$message .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>" . $data . "</td></tr>"
$message .= "</table>";
$message .= "</body></html>";
mail($to,$subject,$message,$headers);
and data here it's undefined also had the 500 (Internal Server Error) when trying to send it. How to get the data correctly here? Thanks a lot