I am trying to grab information from a form and AJAX it to a PHP file that saves it to a csv file, but for some reason, the php file is receiving the Javascript object with empty fields, even though they appear filled in the console
Here is how my code looks like:
var contact_info_list = {company_name: "", contact_name: "", email: "", phone: ""};
contact_info_list gets populated as the user interacts with the form, then I send it using
$.ajax({
url: 'grab_contact_info.php',
type: 'POST',
data: JSON.stringify(contact_info_list),
dataType: 'json'
})
And then here is my php code where I grab that object
$contact_info = json_decode(file_get_contents('php://input'), true);
Can someone please tell me, what am I missing here ?