I have a modal for my login form. I submit the login form using Ajax. If username and password were invalid, I display a message to inform user about failure But if login data was valid, I'd like to redirect the user to dashboard.php Here is what I wrote in php file for response:
$action = $_GET['action'];
if($action=="checkLogin")
{
    $result = check_login();
    if($result=="failure")
    {
        echo "login failed";
    }
    else
    {
        echo 'success
        <script>
        window.location = "dashboard.php";
        </script>
        ';
    }
}
But it is not working as I expect. "failure" and "success" are shown, but redirect does not happen in case of success Please help me were I am wrong? Thanks in advance
 
     
     
     
     
    