PHP not redirecting when working with Jquery post
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/199099/how-to-manage-a-redirect-request-after-a-jquery-ajax-call">How to manage a redirect request after a jQuery Ajax call</a>  </p>
</blockquote>



<p>I have a form that is validated client-side with Jquery. Jquery then passes this data to a php script for server-side validation. At the end of the php script, I try to redirect upon success, but no re-direction happens. </p>

<p>Is Jquery interfering with the redirection? How can I get the php script to redirect. Don't want to redirect with jquery, bc I am going to use sessions and want to keep the session data at redirection.</p>

<p>Here is the code:</p>

<p>JQUERY:</p>

<pre><code>$.ajax({
                    //this is the php file that processes the data and send mail
                    url: "includes/process/processAdminLogin.php",
                    //POST method is used
                    type: "POST",
                    //pass the data        
                    data: dataString,    
                    //indicate result is text
                    dataType: "text",
                    //Do not cache the page
                    cache: false,
                    //success
                    success: function (data) {
                        $('input').removeAttr('disabled'); //enable input fields again.

                        if(data == "fail"){
                            $("#statusMessage").html("");
                            $("#statusMessage").html("&lt;p class='statusBoxWarning'&gt;Username and password do not match!&lt;/p&gt;");
                            $('button').removeAttr('disabled');
                            document.forms[0].reset();
                        }                               
                    }
                }); 
</code></pre>

<p>PHP</p>

<pre><code>if($correctPass == 1){
ob_start();
session_start();
$_SESSION['usernameIdentity'] = $userName;
unset($userName, $userPass);
header("Location: ../../adminDashboard.html");
exit;
}else{
echo "fail";
}
</code></pre>

<p>The php script gets to the redirection part and just hangs up. I would really want to keep jquery functionality, along with php redirection. Is there a better method?</p>

<p>Thanks!</p>

<pre><code>                              FINAL WORKING SOLUTION:
</code></pre>

<p>Ok, after the input from this post and other similar posts, this is what I have as the working solution. It may not be the most efficient or prettiest solution, but it works, and will have to do for now.</p>

<p>JQUERY</p>

<pre><code>$.ajax({
                    //this is the php file that processes the data and send mail
                    url: "includes/process/processAdminLogin.php",
                    //GET method is used
                    type: "POST",
                    //pass the data        
                    data: dataString,    
                    //indicate result is text
                    dataType: "text",
                    //Do not cache the page
                    cache: false,
                    //success
                    success: function (data) {
                        $('input').removeAttr('disabled'); //enable input fields again.
                        if(data == "success"){
                            $('#statusMessage').html('&lt;form action="http://www.example.com/test/userRegistration/adminDashboard.html" name="userSubscription" method="post" style="display:none;"&gt;&lt;input type="text" name="username" value="' + reg_contact_username + '" /&gt;&lt;input type="text" name="password" value="' + reg_contact_password + '" /&gt;&lt;/form&gt;');
                            document.forms['userSubscription'].submit();
                        }else{alert("couldn t redirect");}                              

                    }
                }); 
</code></pre>

<p>PHP</p>

<pre><code>if($correctPass == 1){
echo "success";
}else{
echo "fail";
}
</code></pre>

<p>The receiving redirection page will have to verify username and password being given again, so validation will be done 2x...which is really inefficient. If anybody can provide me with a better solution - please! A sample write out would also help out. </p>

<p>Thanks!</p>
