Jump to content

Recommended Posts

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 !! 

Link to comment
https://forums.phpfreaks.com/topic/288427-re-direct-php-page-with-ajax/
Share on other sites

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

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 by davidannis
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.