Thank you for sharing in my headache – here is the short speil:
Recently inherited a poorly coded WordPress site – which leveraged a WP Contact Form 7 –
I stripped all the WP-CF code out (due to the fact that the WordPress had been stripped out before it was handed over to me) — just to make a simple patch script and get on with real work.
I replaced the WPCF scripts with this one: (to make things as easy as possible for me):
jQuery(document).ready(function() {
$ = jQuery;
console.log("Ready");
$("#quack-button").click(function(e) {
console.log("Quack");
e.preventDefault();
e.stopPropagation();
POSTDATA = $.param($("#quack-form").serializeArray());
$.ajax({
method : "POST",
url : "http://www.domain.com/contact.php",
data : POSTDATA,
success : function(response) {
console.log(response);
alert("Thank you ! We'll get in touch as soon as we can -! ");
}
});
});
});
but, after trying many different forms/combinations of $.param
and serialize
–
The server side script continued to return a blank array….
print_r($_POST);
However, when I changed it to print_r($_REQUEST)
– it all worked, fine….
Now, what possible ways could this even happen? What blindspots am I missing that could create this sort of scenario…?
This is the most baffling I’ve dealt with in some time… I appreciate any understanding anyone can throw at this…
If you want to send it as
$_POST
, change this line:to this:
According to docs, thats the way of setting it.