I want to submit some data from localStorage to
Autoform.submitStoredData = function() {
var data = localStorage.tbRecoveredData;
if(data) {
jQuery.ajax ({
type: "POST",
url:"http://www.thewebsite.com/Autoform.php",
data: data,
success: function() {
console.log("success");
},
error: function(xhr,status,error) {
console.log("payload failed to submit with xhr: " + xhr + ", status: " + status + ", and error: " + error);
}
});
localStorage.removeItem("tbRecoveredData");
}
};
I am getting "success" in the console so far so good. Autoform PHP looks like this:
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$data = $_POST;
mail('myemail@gmail.com', 'OK SO here at least is the captured string', $data);
}
?>
This does nothing or at least no email gets sent. I admit I dont know much about PHP, I've tried googling without much luck. Do I need to wrap this in a sort of self invoking function or something because it seems like the PHP code is not being executed. Any help is appreciated thanks!