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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:07:20+00:00 2026-05-26T13:07:20+00:00

Need your help, trying to change this script: https://github.com/MrHus/jquery-monthly-ical To load external JSON data

  • 0

Need your help, trying to change this script:
https://github.com/MrHus/jquery-monthly-ical

To load external JSON data files. So not local in the javascript or with a PHP array with JSON but a real .json data file.

This is the current script:

    $(document).ready(function()
    {   
        $("#ical").ical({
            /*beforeMonth:function(date)
            {
                $.ajax({
                    type: "GET",
                    url: "action.php",
                    dataType: "json",
                    data: "date="+date,
                    async: false,
                    success: function(json){
                        $.fn.ical.changeEventDates(json); 
                    }   
                })
            },*/
            //daynames: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
            //startOnSunday: true,


              eventdates: [{"date": "2009-03-21", "title": "My birthday", "desc": "Its my birthday!"},
                         {"date": "yyyy-01-01", "title": "New Year", "desc": "Its a new year!"},
                         {"date": "2009-mm-01", "title": "New Month", "desc": "First day of the new month!"},
                         {"date": "2010-mm-01", "title": "New Month", "desc": "First day of the new month!"},
                         {"date": "2010-09-01", "title": "Convention", "desc": "September convention."}, 
                         {"date": "2010-09-02", "title": "Convention", "desc": "September convention day two."}, 
                         {"date": "2010-mm-01", "title": "Towl", "desc": "Dont forget to bring a towl."}    
                        ]
        });
    });

How can I use a .json file with the same data as: But the eventdates: line must be before it in the JavaScript because I dont have this in my JSON files.

    eventdates: [{"date": "2009-03-21", "title": "My birthday", "desc": "Its my birthday!"},
                         {"date": "yyyy-01-01", "title": "New Year", "desc": "Its a new year!"},
                         {"date": "2009-mm-01", "title": "New Month", "desc": "First day of the new month!"},
                         {"date": "2010-mm-01", "title": "New Month", "desc": "First day of the new month!"},
                         {"date": "2010-09-01", "title": "Convention", "desc": "September convention."}, 
                         {"date": "2010-09-02", "title": "Convention", "desc": "September convention day two."}, 
                         {"date": "2010-mm-01", "title": "Towl", "desc": "Dont forget to bring a towl."}    
                           ]

Currently no succes showing my JSON data from the file. This is the part of the JavaScript that handles the JSON. But not working, please help.

            var month = getMonthNumber($("#currentmonth", obj).text());
            var year = $("#currentyear", obj).text();

            var formatdate = formatDate(year, month, i);

            var jsondates  = getEventDates(formatdate)

            if (jsondates.length === 0)
            {
                options.beforeDay(formatdate);
                $(".icaltable tr:last", obj).append("<td id = '"+formatdate+"'>"+i+"</td"); //add day
            }
            else
            {
                var firstEvent = true;
                for (var k = 0; k < jsondates.length; k++)
                {
                    var datejson = jsondates[k];
                    options.beforeDay(formatdate);

                    //alert(datejson.title);

                    var str = "<li><span class='title'>"+ datejson.LOCATION +"</span><span class='desc'>"+ datejson.SUMMARY +"</span></li>"

                    if (firstEvent)
                    {
                        $(".icaltable tr:last", obj).append("<td class='date_has_event' id = '"+ formatdate +"'>"+i+"<div class='events'><ul id ='ul-"+ formatdate +"'>"+ str +"</ul></div></td>"); //add day  
                        firstEvent = false;
                    }
                    else
                    {
                        $("#ul-" + formatdate, obj).append(str);
                    }
                }
            }
        };

        if (options.startOnSunday){
            startOnSunday = 1;
        } 

        for (var i = 0; i < afterpadding - startOnSunday; i++) //add after padding
        {
            $(".icaltable tr:last", obj).append("<td class = 'padding'></td");
        }

        highlightToday(obj);
    };

    function getMonthNumber(month){
        for (var i = 0; i < options.monthnames.length; i++)
        {
            if (options.monthnames[i] === month)
            {
                return i;
            }
        }
    };

    function getDaysInMonth(year, month){
        return 32 - new Date(year, month, 32).getDate();
    };

    function highlightToday(obj){
        var today = new Date();
        today = formatDate(today.getFullYear(), today.getMonth(), today.getDate());
        $("#"+today, obj).addClass("today");
    };

    function getEventDates(date){

        var results = [];

        for (var i = 0;  i < eventdates.length; i++)
        {     
            var evaldate = evaluateEventDate(eventdates[i]["DTSTART"], date);
            if (date === evaldate)
            {
                results.push(eventdates[i]);
            } 
        }

        return results;
    };

    function evaluateEventDate(eventdate, date){
        var eventdate = eventdate.split('-');
        var date = date.split('-');

        if (eventdate[0] === 'yyyy')
        {
            eventdate[0] = date[0];
        }

        if (eventdate[1] === 'mm') 
        {
            eventdate[1] = date[1];
        }

        if (eventdate[2] === 'dd')
        {
            eventdate[2] = date[2];
        }

        return eventdate[0]+'-'+eventdate[1]+'-'+eventdate[2];
    };

    function getLastDayOfMonth(year, month, days){
        var date = new Date(year, month, days);
        if (date.getDay() == 0)//we start on monday!
        {
            return 6;
        }
        else
        {
            return date.getDay() -1;
        }
    };

This is the json data example:

            [
  {
    "DTSTAMP": "20010101T000000Z", 
    "DESCRIPTION": "Hartel-Kuwait", 
    "TRANSP": "TRANSPARENT", 
    "SUMMARY": "HW ", 
    "LOCATION": "Hartel", 
    "DTEND": "20110816", 
    "DTSTART": "20110815", 
    "CATEGORIES": "Tide20110815HARTKWT", 
    "UID": "0.625169509629817"
  }
            ]
  • 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-26T13:07:21+00:00Added an answer on May 26, 2026 at 1:07 pm

    I think you are close with your commented out code.

    It says that before every month is loaded it will use AJAX to get the event dates from the source you specify.

    In the example, it tries to get events from the action.php script. However, if you want to use a hardcoded .json file for every month, you can simply replace action.php with test.json.

    Your new code could be:

    <script type="text/javascript">
        $(document).ready(function()
        {   
            $("#ical").ical({
                beforeMonth:function(date)
                {
                    $.ajax({
                        type: "GET",
                        url: "test.json",
                        dataType: "json",
                        async: false,
                        success: function(json){
                            $.fn.ical.changeEventDates(json); 
                        }   
                    })
                }
            });
        });
    </script>
    

    I haven’t actually used this particular library, but have used ones with a very similar syntax.

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

Sidebar

Related Questions

ive being trying to cope with this problem but still. I need your help.
Need your help figuring this thing out. Scenario: On my JSP, I am trying
I really need your help for this. I am relatively new to programming and
Need your help. I'm trying to create a page that has two UI states.
I need your help. I am trying to import a C Dll into a
I need your help, For example I have a decimal type variable and I
I need your help to define a special case in XML schema: A sequence
I really need your help in my issue very quickly and it's too close
I'm completely stuck and need your help... I've created a webservice stub with jaxb
Dear friends, I need your help. I need to send .bmp file to another

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.