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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:58:55+00:00 2026-05-25T09:58:55+00:00

i’m trying to pass the data i got from the function initiated by onChangeMonthYear

  • 0

i’m trying to pass the data i got from the function initiated by onChangeMonthYear to the function initiated by beforeShowDay. I tried various methods, like assigning the data I got from test.php to a variable declared at the outside but to no avail. so what i did was just update a text field with the retrieved data from test.php, and asks the function in beforeShowDay to get the data from there. here’s a portion of my code

$(document).ready(function() {

    $('#datepicker').datepicker({dateFormat: 'dd-mm-yy', currentText: 'Now', changeMonth: true, changeYear: true, altField: '#alternate', altFormat: 'DD, d MM, yy', onSelect:  function(dateText, inst) {}, 
        onChangeMonthYear: function(year,month,inst){
            $.post("test.php", {action: "TEST", month: month, year: year}, 
            function (data){
                $("#datafromphp").val(data);
            }
            ,"html");
        }, 
        beforeShowDay: function (date){
            var getdatafromphp= $("#datafromphp").val();

        }
    });
});

surely there’s a better way to do this?

  • 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-25T09:58:56+00:00Added an answer on May 25, 2026 at 9:58 am

    If I understand you correctly, you want to grab some data via AJAX asynchronously in onChangeMonthYear and make it accessible in beforeShowDay in order to display the updated data.

    It helps to understand the order of the calls. When the calendar first appears, a bunch of calls are made to beforeShowDay. At this stage, there is no data from your AJAX call yet (i.e. from test.php).

    Once the user changes the month/year, onChangeMonthYear will be called, and a bunch of calls are then made to beforeShowDay again. At this stage, there should still be no data from your AJAX call, unless the AJAX call to test.php manages to return quickly enough for some of the calls to beforeShowDay to access the returned value.

    Then the AJAX call returns and the returned data is somehow passed to beforeShowDay to display.

    As you can see, what you tried to do would not work, as the AJAX call would not be on time for beforeShowDay to grab the data even if you “pass” it correctly. What you want to do is, assign the returned data from AJAX somewhere, and then refresh the datepicker, so beforeShowDay would be called again. You can store data to an arbitrary jQuery object with .data(). So, you can do something like this:

    $('#datepicker').data('datafromphp', []).datepicker({dateFormat: 'dd-mm-yy', currentText: 'Now', changeMonth: true, changeYear: true, altField: '#alternate', altFormat: 'DD, d MM, yy', onSelect:  function(dateText, inst) {}, 
        onChangeMonthYear: function(year,month,inst){
            $.post("test.php", {action: "TEST", month: month, year: year}, 
            function (data){
                $("#datepicker").data('datafromphp', data).datepicker('refresh');
            }
            ,"html");
        }, 
        beforeShowDay: function (date){
            var getdatafromphp= $(this).data("datafromphp");
    
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.