Pawan_Agarwal Posted May 12, 2014 Share Posted May 12, 2014 I know how to implement ajax with php and get output with the help of java-script and ajax... Well, I am just trying to re-direct the page using ajax, but, it is not happening........ What I am doing is that after user logged-in successfully, the email and password are going to check by ajax and if the inputs are correct, the page must re-direct to another page... So, far I am able to verify the correct details, but, the page is not re-directing... You must also see that I want to re-direct the page with ajax only................I am able to redirect the page with java-script but I do not want to include re-direction with java-script in my website !! Thanks for helping me out !! Quote Link to comment https://forums.phpfreaks.com/topic/288427-re-direct-php-page-with-ajax/ Share on other sites More sharing options...
trq Posted May 12, 2014 Share Posted May 12, 2014 Redirecting a page with Ajax? That makes no sense at all. Do you know what Ajax is? Quote Link to comment https://forums.phpfreaks.com/topic/288427-re-direct-php-page-with-ajax/#findComment-1479161 Share on other sites More sharing options...
Pawan_Agarwal Posted May 12, 2014 Author Share Posted May 12, 2014 I have java -script code <script type="text/javascript"> function findName() { str = document.getElementById("num").value; var xmlhttp; if (str=="") { document.getElementById("answer").innerHTML=""; return; } 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) { document.getElementById("answer").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","details.php?q="+str,true); xmlhttp.send(); } </script> ################### details.php ################### <?php echo $_REQUEST['q']; ?> ################### details.php ################### when user click on button, details.php execute and it prints on the page , I understand this as ajax Quote Link to comment https://forums.phpfreaks.com/topic/288427-re-direct-php-page-with-ajax/#findComment-1479198 Share on other sites More sharing options...
trq Posted May 12, 2014 Share Posted May 12, 2014 So, how does it make sense to use ajax to redirect a user to another page? Quote Link to comment https://forums.phpfreaks.com/topic/288427-re-direct-php-page-with-ajax/#findComment-1479204 Share on other sites More sharing options...
Pawan_Agarwal Posted May 14, 2014 Author Share Posted May 14, 2014 You know well, how gmail redirects page after login, I want to have the same feature ... Quote Link to comment https://forums.phpfreaks.com/topic/288427-re-direct-php-page-with-ajax/#findComment-1479409 Share on other sites More sharing options...
davidannis Posted May 14, 2014 Share Posted May 14, 2014 (edited) I think you should just submit and use php header() to redirect. Using Ajax is great to save time and bandwidth so the entire page need not be retransmitted from the server but there is no advantage to using it to redirect since after the redirect the server will transmit the entire page anyway. Even if you can get it to work it does not save you time or bandwidth. Edited May 14, 2014 by davidannis Quote Link to comment https://forums.phpfreaks.com/topic/288427-re-direct-php-page-with-ajax/#findComment-1479480 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.