Have a form with method=post, see below:
<form action="/includes/process.php" method="post">
<input type="hidden" name="breakDown" value="1" />
<input type="hidden" name="string" value="2" />
<a href="javascript:;" class="btn btn-primary itemCheckout add-cart formSubmitCheckout">Checkout</a>
</form>
And this is the JS that submits the form when user clicks over Checkout link (<a>
):
$('.formSubmitCheckout').click(function() {
var t=$(this);
var isItemCheckout = t.hasClass('itemCheckout');
var form = t.parents('form');
if(!isItemCheckout) {console.log('testOk');console.log($('form').serialize());
form.submit();
}
});
The code redirects us to the proper location process.php as it should be, but the array $_POST is not being created. This is what I get in intellij:
I've tried the same proccess in Firefox and Safari and the result is the same: no $_POST.
if (isset($_POST['string'])) { display something ...
Doing a console.log($('form').serialize());
inside $('.formSubmitCheckout'){...
I can see the variable 'string' (this the variable name) string=type%3Dpurchase%26priceAmo
.
So the point here is that the $_POST is not being created at php side in process.php.
Does someone knows what is happening and can explain how to fix it?