I'm doing a POST using AJAX and I'm checking for the response with PHP using
if (!empty($_POST)
but it doesn't seem to be hitting the if or else.
The form is submitting and I get a 200 status in the network tab.
PHP isn't my main language so I'm wondering if I'm missing something relatively simple?
Thanks
Form:
<form id="myForm" method="post" novalidate="novalidate">
...
<button type="submit" name="contact_send">Send</button>
</form>
AJAX:
jQuery.ajax({
type: 'POST',
url: window.location.href,
data: formData,
success: function(response) {
console.log('response');
}
});
PHP:
if (!empty($_POST)) {
print_r('Data');
add_action('init', 'deliver');
} else {
print_r('No Data');
}
Neither the if or else is reached
Aucun commentaire:
Enregistrer un commentaire