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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:24:49+00:00 2026-05-12T17:24:49+00:00

I got a little problem here guys. I’m trying to implement the following scenario:

  • 0

I got a little problem here guys. I’m trying to implement the following scenario:

  1. A user opens the home page and sees a list of other users and clicks
    to add one to his friend list.
  2. I issue an Ajax request to a server resource to validate if the user
    is logged in, if so, I issue another ajax request to another server
    resource to actually add it to the user’s friend list.

Sounds simple? Here’s what I’ve done: I created a function isLoggedIn that will issue the first request to the server in order to determine if the user is logged in. I issue this request using jQuery.ajax method. Here’s my function looks like:

function isLoggedIn() {

    $.ajax({
    async: "false",
        type: "GET",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        url: "/isloggedin",
        success: function(jsonData) {
            alert("jsonData =" + jsonData.LoggedIn);
            return jsonData.LoggedIn;
        }
    });
}

The returned JSON is very simple, it looks like the following:

{ LoggedIn: true } or { LoggedIn : false } 

Now this method, actually works and displays the alert correctly: JsonData = true if logged in, and JsonData = false if not logged in.
Up to this point there’s no problem, the problem occurs when I try to call this method: I call it like so:

$(".friend_set .img").click(function() {
    debugger;
    if (isLoggedIn()) { 

        alert("alredy logged in");
        trackAsync();
        popupNum = 6;
    }
    else {
        alert("not logged in"); //always displays this message.
        popupNum = 1;
    }
    //centering with css

    centerPopup(popupNum);
    //load popup
    loadPopup(popupNum);
    return false;

});

Calling isLoggedIn always returns false, and it returns false before the ajax request finishes (because the messagejsonData = trueis displayed after the message "not logged in". I made sure that the request is **NOT** Asynchronous by statingasync: false`!

Apparently it’s still working asynchronously, though. What am I missing here guys?

  • 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-05-12T17:24:49+00:00Added an answer on May 12, 2026 at 5:24 pm

    You need async:false, not async:"false". (i.e. pass boolean false, not string "false").

    Edit:
    also with async requests you need to return a value after the call to ajax, not inside your success handler:

    function isLoggedIn() {
        var isLoggedIn;
        $.ajax({
            async: false,
            // ...
            success: function(jsonData) {
                isLoggedIn = jsonData.LoggedIn
            }
        });
        return isLoggedIn 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 335k
  • Answers 335k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer __FILE__ and __LINE__ are sort of dynamic constants that hold… May 14, 2026 at 3:38 am
  • Editorial Team
    Editorial Team added an answer There are no one-size-fits-it-all tools. Triple stores are appropriate and… May 14, 2026 at 3:38 am
  • Editorial Team
    Editorial Team added an answer Assuming you're talking about the output of XSD.EXE, it pays… May 14, 2026 at 3:37 am

Related Questions

I got a little problem here guys. I'm trying to implement the following scenario:
Guys i need some help here , im getting this error here at the
I'm trying do to a basic bash with the use of system calls but
I'm learning Java by making a small game in a JApplet. I got a
I've got a little problem: I don't know whether it is possible to select

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.