locked
How to use FullCalendar JS variable in ASPX page RRS feed

  • Question

  • User-1241097802 posted

    I am using fullcalendar in my project. When i click on next,previous,today button i want to perform certain operation.

     $(".fc-today-button").click(function () {
                alert('Clicked Today!');
                //var fetchDate = $(this).data("date");
                //alert(fetchDate);
                var b = $('#calendar').fullCalendar('getDate').format("YYYY-MM-DD");
                alert(b);
            });
            $('.fc-prev-button').click(function () {
                alert('prev Button is is clicked');
                var b = $('#calendar').fullCalendar('getDate').format("YYYY-MM-DD");
                alert(b);
            });
    
            $('.fc-next-button').click(function () {
                alert('next button is clicked');
                var b = $('#calendar').fullCalendar('getDate').format("YYYY-MM-DD");
                alert(b);
            });

    Now all the above code is inside the calendarscript.js file. now i want to use this variable in my schedular.aspx page 

    <script type="text/javascript">
            $(document).ready(function () {
               
                var checkedvalue = [];
                
                $.ajax({
    
                    type: "POST",
    
                    url: "SchedulerMaster.aspx/GetRole",
    
                    //data: '',
                    data: JSON.stringify({ "date": "2020-02-08" }),
    
                    contentType: "application/json; charset=utf-8",
    
                    dataType: "json",

    As u can see in above code i am passing the constant date "2020-02-08", but i want to use the Variable "B" here. How can i use ?

    Friday, February 7, 2020 6:02 PM

Answers

  • User475983607 posted

    The AJAX function runs when the page loads.  The var b is set when the the user clicks a button.  Since the AJAX functions always runs first, your code need to read the user's mind.

    Do you want to do an AJAX request when the user clicks a button?  Do you want to get a value from the calendar in the AJAX function?  Can you explain how the application is intended to function?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 7, 2020 7:43 PM

All replies

  • User475983607 posted

    The AJAX function runs when the page loads.  The var b is set when the the user clicks a button.  Since the AJAX functions always runs first, your code need to read the user's mind.

    Do you want to do an AJAX request when the user clicks a button?  Do you want to get a value from the calendar in the AJAX function?  Can you explain how the application is intended to function?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, February 7, 2020 7:43 PM
  • User-1241097802 posted

    it is working now sir. thank you for your reply 

    Saturday, February 8, 2020 6:40 PM