I have the following code in my javascript:
$.ajax({
url : 'update_data.php',
type : 'POST',
data : 'asdfasd', //d,
success : function(response){
console.log(response);
},
error: function(jqXHR, textStatus, errorThrown){
console.log('jqXHR.responseText: ' + jqXHR.responseText);
console.log('jqXHR.responseXML : ' + jqXHR.responseXML);
console.log('textStatus: ' + textStatus);
console.log('errorThrown: ' + errorThrown);
},
dataType : 'text'
});
Here is my 'update_data.php' :
<?php
echo json_encode($_POST);
if (isset($_POST['data'])){
echo "here!";
} else {
echo "failed jquery";
}
?>
When I run the Ajax method, I get the following response in my console:
[]failed jquery
meaning update_data.php didn't get any POST request. '[]' is from json_econd($_POST), and 'failed jquery' is from the if/else.
What am I doing wrong?