Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8325069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:18:29+00:00 2026-06-09T00:18:29+00:00

i am trying to refresh the page upon successful login in the Ajax script

  • 0

i am trying to refresh the page upon successful login in the Ajax script but the page is not refreshed. I am forced to refresh the page manually and only then will it appear to be logged in. Thanks in advance for any help, it is much appreciated.

This is the login script for ajax;

$("document").ready(function() {
    $("#what").click(function() {
        var email = $("#emailLogin").val();
        var password = $("#passwordLogin").val();
        var dataString = 'email='+email+'&password='+password;
        $.ajax({
            type: "POST",
            url: "authenticate.php",
            data: dataString,
            success: function(response){                
                //alert (response);
                if (response == 0) {
                $("#problem").html("Please enter correct details");
                            } else {
                    window.location = "index.php";
                }
            }
        });
    return false;
    });
});

This is the php script for validating the form

// authenticate.php

session_start();
require_once "database.php";
db_connect();
require_once "auth.php";


$user_id = credentials_valid($_POST['email'], $_POST['password']);

if($user_id){
  log_in($user_id);
  if($_SESSION['redirect_to']){
    header("Location: " . $_SESSION['redirect_to']);
    unset($_SESSION['redirect_to']);
  }else{
    header("Location: index.php");
  }

}else{
  echo "0";

}

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:18:31+00:00Added an answer on June 9, 2026 at 12:18 am

    Of course you need to refresh the page because you post with JQuery and the php function only returns some data.

    You have 2 alternatives:

    1. Post the classic way (form submit)

    2. Redirect from javascript using window.location=’url’;

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a user interface, but when I refresh the page,
I am trying to refresh the page with ajax whenever a button to submit
I am trying to refresh a page, but WANT to use the cache and
While I was trying to refresh page contents dynamically using Ajax/JQuery, I have learned
I am trying to refresh a certain part of my page with AJAX and
I'm trying to refresh a page without sending POST from the previous time. I've
I am trying to refresh the page after a cgi execution. In my cgi,
I am trying to use periodic refresh(ajax)/polling on my site by XMLHttp(XHR) to check
I'm trying to get a page to refresh when navigated to from the back
I'm trying to use form submit with jquery without a page refresh as demonstrated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.