Alert After Executing Php Script While Not Leaving Current Page
Solution 1:
This is not easy... You could do it like this if you submit your form into an IFRAME, but that's considered out of fashion today. However, with minimal changes it can work with your current code - you only have to change the form tag and add an iframe element:
<iframename="myIframe"id="myIframe"></iframe><formaction="updateUserConfig.php"method="post"target="myIframe">
This way you can alert after the POST, but since the receiving php will run inside the iframe, you'll have to use javascript to navigate the parent (the original) page. That part is easy - just very unusual. You'll have to do a
parent.location="mynextpage.php"
to make that happen. Also, this has limitations for the cross-domain thing too. (For these issues, google for "Access-Control-Allow-Origin" which is the official solution - and you'll probably see some dirty workarounds too.)
With AJAX, of course, everything is different. But I can't explain that in a single post - it needs a reversed approach, you submit the form, get something back from the php script that handled the post and then your original javascript will make the alert. I wouldn't recommend this way if you haven't done it before.
Post a Comment for "Alert After Executing Php Script While Not Leaving Current Page"