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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:48:47+00:00 2026-05-27T01:48:47+00:00

I’ll try and keep this short and to the point. I’ve got a datePicker

  • 0

I’ll try and keep this short and to the point.

I’ve got a datePicker set up that is being used for an accommodation website to set check in / check out dates. I’m using beforeShowDay to request an XML file that contains date availability and the rate. I’ve got this set up and working correctly.

When the month is changed I have an onMonthChange function to re-request information for the following / previous months dates, this also works as expected, except for one important part:

The Problem:
If you quickly click through the months the XML data coming back in can’t keep up, so dates incorrectly show as unavailable.

I need one of the following to happen:

  • Once the data loads the calendar refreshes to show the correct availability
  • The month forward button is disabled until the data has been loaded.

What I’ve Tried

  • Hiding the month change button at the start of the onMonthChange
    function then showing it at the end – this doesn’t work.
  • Using async:false in the get function – I feel this is the solution
    but I can’t get it work as I can’t find any clear documentation on
    where it’s meant to go.

Code:

        /* Date Picker */
    var datepickerOptions = {
        dateFormat: 'yy-mm-dd',
    };
    var checkInOptions = {
        showOtherMonths: false,
        minDate: 0,
        beforeShowDay: addPrice,
        onSelect: openCheckout,
        onChangeMonthYear: onMonthChange,
        dateFormat: 'yy-mm-dd'
    };

    j.getJSON("/availability.php?startDate="+year+"-0"+month+"-01&id="+j('#property_id').text(),
      { format: "json" },
      function(data) {
            document.pricesData = data;
            document.firstDate = '';
            j('#calendar_check_in').datepicker(checkInOptions);

            /* Tip Tip */
            j('.ui-datepicker-calendar td').tipTip({ defaultPosition: "right" });

            for (var key in document.pricesData) {
               var obj = document.pricesData[key];
               if(obj['avail'] == 1 && document.firstDate == ''){
                  document.firstDate = key;
               }
            }
            d = new Date(document.firstDate.substr(5));
            d.setMonth(d.getMonth()+1);

      });

function addPrice(date) {
    calDate = new Date(date);
    dateString = 'date_'+calDate.getFullYear()+'-'+('0'+(calDate.getMonth()+1).toString()).substr(-2)+'-'+('0'+(calDate.getDate()).toString()).substr(-2);
    if(document.pricesData[dateString] != undefined){
        var priceString = document.pricesData[dateString]['price'];
        if(document.pricesData[dateString]['avail'] == "1"){
            valid = true;
        } else {
            valid = false;
        }
    }else{
        var priceString = 'Price not available';
        valid = false;
    }
    return [valid, '', priceString];
}

function onMonthChange(year, month, inst){
    /* Date Picker */
    month--;
    j.getJSON("/availability.php?startDate="+year+"-0"+month+"-01&id="+j('#property_id').text(),
      { format: "json" },
      function(data) {
            document.pricesData = data;
            document.firstDate = '';
            /* Tip Tip */
            j('.ui-datepicker-calendar td').tipTip({ defaultPosition: "right" });

            for (var key in document.pricesData) {
               var obj = document.pricesData[key];
               if(obj['avail'] == 1 && document.firstDate == ''){
                  document.firstDate = key;
               }
            }
            d = new Date(document.firstDate.substr(5));
            d.setMonth(d.getMonth()+1);
      });
}

Thanks to anyone who takes the time to read this, hoping someone has some sort of solution for as it’s a bit of a show stopper at the moment!

Thank you!

  • 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-27T01:48:48+00:00Added an answer on May 27, 2026 at 1:48 am

    If you quickly click through the months the XML data coming back in
    can’t keep up, so dates incorrectly show as unavailable.

    When the user changes months in the datepicker, couldn’t you clear the currently displayed pricing and availability information? That way at least you wouldn’t have incorrect data displayed. Then, if needed, you could add some message informing the user that the other data is still loading.

    I would recommend strongly against trying to use async:false. That is like the nuclear option. It will have other adverse affects to the site and doesn’t sound like it is really needed in your case.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.