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. 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 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
Archived
This topic is now archived and is closed to further replies.