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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:32:20+00:00 2026-06-03T05:32:20+00:00

I am trying to get an event calendar working from json data. I just

  • 0

I am trying to get an event calendar working from json data. I just want to highlight dates, and have a div update below the calendar with the event details when the user clicks on a date. My app serves the JSON in the form:

[
  {"Date":"02/06/2012","Title":"Eat, Bike, and Swim"},
  {"Date":"02/03/2012","Title":"Sleep"},
  {"Date":"02/02/2012","Title":"Laugh"}
]

I have a JS fiddle that works with a variable definition, but I can’t get it to respond to a JSON request.

Here is my best attempt: http://jsfiddle.net/PGmFv/2/

The javascript is:

$(document).ready(function() {
  var dp, events;
  events = [];
  return dp = $(".blog_calendar").datepicker({
    beforeShowDay: function(date) {
      var matching, result;
      $.getJSON("https://raw.github.com/gist/1676157/15ce81851e57dfcecb985039e970a749585959de/my.json", function(data) {
        return events = data;
      });
      result = [true, "", null];
      matching = $.grep(events, function(event) {
        return event.Date.valueOf() === date.valueOf();
      });
      if (matching.length) {
        result = [true, "highlight", null];
      }
      return result;
    },
    onSelect: function(dateText) {
      var date, event, i, selectedDate;
      date = void 0;
      selectedDate = new Date(dateText);
      i = 0;
      event = null;
      while (i < events.length && !event) {
        date = events[i].Date;
        if (selectedDate.valueOf() === date.valueOf()) {
          event = events[i];
        }
        i++;
      }
      if (event) {
        return alert(event.Title);
      }
    }
  });
});

I’m trying to load in the json inside the datepicker function because I want to be able to have multiple calendars on the same page and this.id contains a specific url variable so I can call $.getJSON('/events/' + this.id + '/data.json',function() {}

Any thoughts greatly appreciated. I’m leaning significantly on: Events in jQuery UI Datepicker with json data source and Datepicker with events? but just not able to get the json to load at the right time and in the right way.

The lack of an error in console is not helping.

  • 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-03T05:32:21+00:00Added an answer on June 3, 2026 at 5:32 am

    In order to get JSON data from another domain, you have to use JSONP with a callback function. The Github API supports this (example), and jQuery handles making the callback automatically with dataType: 'jsonp'.

    This is how I get JSON data from a Github gist with jQuery:

    $.ajax({
      url: 'https://api.github.com/gists/'+gistid,
      type: 'GET',
      dataType: 'jsonp'
    }).success( function(gistdata) {
      // This can be less complicated if you know the gist file name
      var objects = [];
      for (file in gistdata.data.files) {
        if (gistdata.data.files.hasOwnProperty(file)) {
          var o = JSON.parse(gistdata.data.files[file].content);
          if (o) {
            objects.push(o);
          }
        }
      }
      if (objects.length > 0) {
        // DoSomethingWith(objects[0])
      }
    }).error( function(e) {
      // ajax error
    });
    

    (jsFiddle)

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

Sidebar

Related Questions

I am trying to get a json feed working for the jquery Full Calendar
I'm making a custom event calendar with PHP. I am trying to get the
I'm basically trying to get the target element from event.target and if not equal
I've been trying to work with the Google Calendar JSON API, but have been
Using Enumerable, I am trying to display dates in an organized event calendar by
I'm trying to insert the description of an event in google calendar from my
I'm trying to get my Chrome extension working with the Google Calendar API. However,
I'm trying to get several informations from google calendar's API in JAVA. While trying
I am trying to get the latest event timestamp for each host, google search
I am trying to get the code of an event using the event.which jQuery

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.