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

  • Home
  • SEARCH
  • 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 7924321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:42:16+00:00 2026-06-03T17:42:16+00:00

I have a log in form that I am trying to submit via AJAX.

  • 0

I have a log in form that I am trying to submit via AJAX. I have a similar form for registration that is working perfect; however, the return false statement isn’t firing.

My log in form looks like this:

  <form name="loginForm" id="loginForm" action="userSystem/userSystem.php" method="post">
    <div class="loginTable">
      <div class="loginRow">
        <div class="loginCell"><label for="username">Username:</label></div>
          <div class="loginCell"><input type="text" name=="username" id="loginFormUser"></div>
        </div>
      <div class="loginRow">
        <div class="loginCell"><label for="password">Password:</label></div>
          <div class="loginCell"><input type="password" name="password" id="loginFormPass"></div>
        </div>
      <div class="loginRow">
        <div class="loginCell">&nbsp;</div>
        <div class="loginCell"><input type="submit" name="submit" value="Log In" id="loginFormSubmit"></div>
      </div>
    </div>
  </form>
</section>
<section id="loginBarRegForm">
  <h1>Step Two</h1>
  <form name="regForm" id="regForm" action="usersystem/register.php" method="post">
    <div class="loginTable">
      <div class="loginRow">
        <div class="loginCell"><label for="r_username">Username:</label></div>
        <div class="loginCell"><input type="text" name="r_username" id="r_username"></div>
        <div class="loginCell"><span id="r_usernameFeedback"></span></div>
      </div>
      <div class="loginRow">
        <div class="loginCell"><label for="r_password">Password:</label></div>
        <div class="loginCell"><input type="password" name="r_password" id="r_password"></div>
        <div class="loginCell"><span id="r_passwordFeedback"></span></div>
      </div>
      <div class="loginRow">
        <div class="loginCell"><label for"r_vpassword">Verify Password</label></div>
        <div class="loginCell"><input type="password" name="r_vpassword" id="r_vpassword"></div>
        <div class="loginCell"><span id="r_vpasswordFeedback"></span></div>
        </div>
      <div class="loginRow">
        <div class="loginCell"><label for="email">Email:</label></div>
        <div class="loginCell"><input type="text" name="r_email" id="r_email"></div>
        <div class="loginCell"><span id="r_emailFeedback"></span></div>
        </div>
      <div class="loginRow">
        <div class="loginCell"></div>
        <div class="loginCell"><input type="submit" name="r_submit" value="Register" id="r_submit"></div>
        <div class="loginCell"></div>
        </div>
      </div>
  </form>

And the javascript that I’m trying to execute when the submit button is clicked on

$("#loginFormSubmit").click(function() {
  form_data = {
    username: $("#loginFormUser").val(),
    password: $("#loginFormPass").val(),
    operation: "login",
    is_ajax: 1
  }

  $.ajax({
    type: "POST",
    url: "userSystem/userSystem.php",
    data: form_data,
    dataType: json,
    success: function(data) {
      if(data.success) {
        $("#loginBarLoginForm").fadeOut("slow");
        $("#userDetailsUsername").html(data.username);
        $("#userDetailsEmail").html(data.email);
        $("#userDetails").fadeIn('slow');
      } else {
        $("#loginbarLoginForm").fadeOut("slow");
        $("#loginBoxResponseDiv").html(data.message);
        $("#loginBoxResponseFrame").fadeIn("slow");
      }
    }
  });
  return false;
});

So far this is about the most in depth application I’ve developed, but it just doesn’t make sense as to why return false will work in one instance, but not another. They are nearly identical functions except for the data.

Thank you for any help you can provide 🙂

EDIT: Updated Code.

    $("#loginFormSubmit").click(function() {
    console.log("Click Event Firing");
    var form_data = {
        username: $("#loginFormUser").val(),
        password: $("#loginFormPass").val(),
        operation: "login",
        is_ajax: 1
    };
    console.log("variables Assigned " + form_data['username'] + " " + form_data ['password']);

    $.ajax({
        type: "POST",
        url: "userSystem/userSystem.php",
        data: form_data,
        success: function(data) {
            console.log("Ajax Working");
            if(data.success === true) {
            $("#loginBarLoginForm").hide();
                $("#loginBoxResponseDiv").html("<p>You have been loged in " + data.username + "!");
                $("#loginBoxResponseFrame").fadeIn("slow");
            } else {
                $("#loginBarRegForm").hide();
                $("#loginBoxResponseDiv").html(data.message);
                $("#loginBoxResponseFrame").fadeIn("slow");
            }
        }
    });
});

The code will now return a JSON respones, but the function for success is not being fired.

  • 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-03T17:42:17+00:00Added an answer on June 3, 2026 at 5:42 pm

    It turns out that all along, I was just missing some quotes in my solution. I needed to replace:

        dataType: json,
    

    with:

        dataType: "json",
    

    Once I got that, the solution came into place and now my users will be able to log in without a page refresh. I still have a long way to go on this project, but thank you all for helping point me in the right direction. Also I feel acomplished that I was able to find the answer on my own; however, I never would have, had it not been for the fine help and tips that I received from the SO community. You guys are one in a million!

    The final solution ended up looking like this:

        $("#loginFormSubmit").click(function() {
        console.log("Click Event Firing");
        var form_data = {
            username: $("#loginFormUser").val(),
            password: $("#loginFormPass").val(),
            operation: "login",
            is_ajax: 1
        };
        console.log("variables Assigned " + form_data['username'] + " " + form_data ['password']);
    
        $.ajax({
            type: "POST",
            url: "userSystem/userSystem.php",
            dataType: "json",
            data: form_data,
            success: function(data) {
                console.log("Ajax Working");
                console.log("data.success: " + data.success);
                console.log("data.username: " + data.username); 
                if(data.success === true) {
                    console.log("data.success was true");
                    $("#loginBarLoginForm").hide();
                    $("#loginBoxResponseDiv").html("<p>You have been loged in " + data.username + "!");
                    $("#loginBoxResponseFrame").fadeIn("slow");
                    $("#notLoggedIn").fadeOut("slow");
                    $("#currentlyLoggedIn").fadeIn("slow");
                    $.cookie("username", data.username, {expires: 7, path: "/"});
                    $.cookie("id", data.id, {expires: 7, path: "/"});
                    $.cookie("email", data.email, {expires: 7, path: "/"});
                    $.cookie("user_level", data.user_level, {expires: 7, path: "/"});
                    $.cookie("active", data.active, {expires: 7, path: "/"});
                    $.cookie("reg_date", data.reg_date, {expires: 7, path: "/"});
                    $.cookie("last_login", data.last_login, {expires: 7, path: "/"});
                    $("#cookieUsername").html($.cookie("username"));
                    $("#cookieID").html($.cookie("id"));
                    $("#cookieEmail").html($.cookie("email"));
                    $("#cookieUserLevel").html($.cookie("user_level"));
                    $("#cookieActive").html($.cookie("active"));
                    $("#cookieRegDate").html($.cookie("reg_date"));
                    $("#cookieLastLogin").html($.cookie("last_login"));
                } else {
                    console.log("data.success was false");
                    $("#loginBarRegForm").hide();
                    $("#loginBoxResponseDiv").html(data.message);
                    $("#loginBoxResponseFrame").fadeIn("slow");
                }
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a login form that I am trying to handle with ajax. At
I have a WPF form that uses ClientLogin to log a user into their
I have a directory full of log files in the form ${name}.log.${year}{month}${day} such that
I have a log file that I'm trying to append data to the end
I'm trying to build a form that will have mixed inputs mostly text and
I have a form that i'm trying to use the jquery validate plugin. My
I have a log in form on my app. Once a correct user name
We've faced strange problem. We have log on service, that authenticates user, adds auth
I have a log method which saves to a file that is named the
I have a log file that I am reading to a string public static

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.