The difference is that when you submit the form, the page request usually also contains the data serialized with it. You submit the form as an AJAX request, and then redirect the user to the page without the data attached to it with the serialized form.
So, if you need the $_POST
variable, which will be available in submitPage.php
, I would let the form send normally, rather than welcome the submission using an AJAX request and then redirect the user.
You can add the $_POST
data to $_SESSION
and then use this when redirecting the user, but if you have no reason for this, it seems like an unnecessary bit of code.
source share