So I learned recently that if you use jquery $.post to post back to a PHP script, that you cannot then do an @header redirect within that script (even if you use exit(); immediately after it).
This is enormously depressing news since I have an important redirect/flash message class that I use a lot after a form submission is successfully executed.
The fact that jQuery post is “greedy” and doesn’t let the php script interrupt it is a huge limitation.
Does anyone know of a solution that will let me ajax post form data back to PHP, and then redirect from within PHP? Duplicating the redirect/flash message class in javascript is not really an option for me.
Does anyone know of a way to overcome this issue?
Your script redirects, and your JavaScript (jQuery) gets the result from the redirect I think, or your return includes a 302: redirect header.
Since your script uses its own request, the redirect you tell it to do will not update the browser, and that functionality will never exist. You have to respond to the request headers from the server in your client side code to respond to whatever you want to do.