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 8990125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:25:52+00:00 2026-06-15T22:25:52+00:00

I am creating a login function with ajax and am having an issue where

  • 0

I am creating a login function with ajax and am having an issue where the success function (SuccessLogin) fires before getting an ajax response. I am running the code as google web app from eclipse and I can see when debugging the java class file, that the javascript is throwing an alert for the success response from the class being false before the debugger catches the break point in the class file. I have only been writing code for a couple months now so I am sure its a stupid little error on my part.

$(document).ready(function() {

    sessionChecker()





    // sign in 
    $('#signInForm').click(function () {        
        $().button('loading') 
           var email = $('#user_username').val();   
           sessionStorage.email = $('#user_username').val();       
           var password= $('#user_password').val();

           var SignInRequest = {
                type: "UserLoginRequest",
                email: email,
                password: password
           }

           var data= JSON.stringify(SignInRequest);



           //disabled all the text fields
           $('.text').attr('disabled','true');

           //start the ajax
           $.ajax({

               url: "/resources/user/login", 

               type: "POST",

               data: data,     

               cache: false,

               success: successLogin(data)
           });       


       });






    //if submit button is clicked
   $('#Register').click(function () {        
        $().button('loading') 
        var email = $('#email').val();       

        if ($('#InputPassword').val()== $('#ConfirmPassword').val()) {
            var password= $('input[id=InputPassword]').val();
        } else {alert("Passwords do not match"); 
            return ;}
        var UserRegistrationRequest = {
                type: "UserRegistrationRequest",
                email: email,
                password: password
        }

        var data= JSON.stringify(UserRegistrationRequest);


        //disabled all the text fields
        $('.text').attr('disabled','true');

        //start the ajax
        $.ajax({

            url: "/resources/user/register", 

            type: "POST",

            data: data,     

            cache: false,

            success: function (data) {              

                if (data.success==true) {                  
                    //hide the form
                    $('form').fadeOut('slow');                 
                    //show the success message
                    $('.done').fadeIn('slow');
                } else alert('data.errorReason');               
            }       
        });

        return false;
    });
}); 

function successLogin (data){
       if (data.success) {                 
            sessionStorage.userID= data.userID
            var userID = data.userID
            sessionChecker(userID);
        } else alert(data.errorReason); 
       }

//session check
function sessionChecker(uid) {
    if (sessionStorage.userID!= null){
        var userID = sessionStorage.userID
    };

    if (userID != null){

        $('#user').append(userID)
        $('#fat-menu_1').fadeOut('slow')                
        $('#fat-menu_2').append(sessionStorage.email).fadeIn('slow') };
}
  • 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-15T22:25:53+00:00Added an answer on June 15, 2026 at 10:25 pm

    success: successLogin(data)

    There’s a difference between a function call and a function definition:

    • A function definion uses the function keyword and contains a function body {...}
    • A function call appends parentheses (argument list) to the function name and actually calls the function to return a value

    If you assign a function call to the property, it will return a value and that will be what is stored. To avoid this, if your function does not take any parameters you can use the function name, or if your function does take a parameter, embed your function call in another function’s definition:

    • No parameter: success: successLogin
    • Has parameter: success: function() { successLogin(data); }
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having trouble getting jQuery ajax to recognise a session. I am creating
We are new to ROR, We have issue in creating Login/Logout process in ROR
I am creating login system with Sencha Touch 2 . I am getting an
Creating a login system for something and am getting: Warning: mysql_result(): supplied argument is
I am playing with Google Calendar API, creating some useful function. I another hand,
i am creating login code for facebook connect on our site, however i cannot
I have a problem in creating an AJAX-based form submission which if its response
Working on an AJAX class. Here is the code: function AjaxRequest(params) { if (params)
I'm getting a function not defined Javascript error with the following code, which uses
I am creating an ajax login and it used to work but for some

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.