I have an AJAX call that is not sending information over to the server from the data parameter. I confirmed it's being recognized as a POST request with my PHP code below. You will notice my var_dump($_POST)
does not contain the 'myData' data. I'm not sure where to go from here.
JavaScript
$.ajax({
method : 'POST',
contentType: 'application/json; charset=utf-8',
url : myURL,
data : {
'myData' : 'myData'
},
async : true,
success: function (results) {
console.log('here are the results: ' + results);
},
error: function (req, msg, obj) {
console.log('An error occured while executing a request');
console.log('Error: ' + msg);
}
});
PHP
if ($_SERVER["REQUEST_METHOD"] == "POST") {
echo var_dump($_POST);
}
Console.log
here are the results: array(1) { ["phpURI"]=> unicode(33) "php/main.php?
function=myFunction" }
Thanks!