anton24 Posted August 12, 2011 Share Posted August 12, 2011 I have a form which action is a php script. That script returns a header('Location: whatever.html'); Now my question is, would be a way through ajax/javascript to do that only the form were sent, but avoid or prevent the redirection to whatever.html? Also, if would be possible know the page where I was going redirected to... but this is secondary, and I'm asking too much. I've tried with: var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { alert(xmlhttp.getAllResponseHeaders()); } } xmlhttp.open("POST","action.php",true); xmlhttp.send(); But in the alert it doesn't give me any Location. Hope you can understand me. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/244594-send-form-to-php-prevent-redirection-with-ajax/ Share on other sites More sharing options...
ZulfadlyAshBurn Posted August 12, 2011 Share Posted August 12, 2011 Basically, you want to have a ajax form. Its easy this page has a good tutorial Open.JS Quote Link to comment https://forums.phpfreaks.com/topic/244594-send-form-to-php-prevent-redirection-with-ajax/#findComment-1256295 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.