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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:11:03+00:00 2026-06-04T10:11:03+00:00

I have narrowed down an earlier question I asked and found out what is

  • 0

I have narrowed down an earlier question I asked and found out what is wrong, but cannot solve it.

I have a variable that needs to be set within one event function BEFORE the next event fires.

This is not happening, because I retrieve the variable via an Ajax call. And even though I think I have all the ajax settings right (?) – it doesn’t happen. I am using console logging in Firebug, and the console log with “2” in it gets logged BEFORE the other log entry that should be made first (with “1” in it).

It’s part of a datepicker instance, with an ajax call. Full code below. By the way – I have taken the ajax call out, and inserted a hard-coded variable to test – and it works perfectly. So it is the ajax that is not working correctly.

The variable ‘varDate’ is declared outside the document ready function:

<script type='text/javascript'>
 var varDate = 'toby';
$(document).ready(function(){

… and the main code here

$('.subject-date-pick').datetimepicker({
    timeFormat: 'hh:mm:ss',
    startDate:'01/01/1996',
    clickInput:true,
    beforeShow: function(input,inst) {

        var source = $("#" + inst.id).attr('source');
        var source_id = $("#" + inst.id).attr('source_id');
        var thing = $.ajax({
            type: 'GET', 
            url: 'ajax_get_unavailable_dates.php',
            dataType: 'text',
            async: 'false',
            global: 'false',
            data: {
                source_type: source,
                source_db_id: source_id
                  },
            success: function(msg) {


                console.log("1 - got the result");

                varDate = (msg)
            }
        });
        console.log("2 - ajax complete - logging console");     
        console.log("Post Ajax"+varDate);

    },

What the console does here is log the variable incorrectly first (with the SECOND logging event), and then the next event for the datepicker fires. After that, the variable IS updated – and subsequent clicks on the datepicker field will have the corrrect variable set – but this is too late and no good.

So: Console results:

GET request for Ajax call

2 – ajax complete – logging console

Post Ajaxtoby

1 – got the result

…

Anyone help?

  • 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-04T10:11:04+00:00Added an answer on June 4, 2026 at 10:11 am

    I’m guessing that this is because 'false' == true 🙂

    Try again with async: false; as the $.ajax ajax options.

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

Sidebar

Related Questions

I have narrowed down my issue to a derived classes copy constructor, but I
I'm working on a bigger problem, but have narrowed it down to this, in
I have narrowed down an ugly bug, but since it seems like something internal
Actually, I have a very complex problem, but I have narrowed it down here
I have narrowed down my problem to the mysql_connect call I am doing in
With Java and Perl background, I have narrowed down the web framework choices to
I have narrowed down this error (which crashes my app): -[NSConcreteMutableData release]: message sent
Based on some standard web searching, I have narrowed down my problem to this:
I am writing a hashing table and have narrowed down where the issue is
I have a requirement to create RESTful web service. I have narrowed down on

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.