1

Hello: I am trying to use the JavaScript library timeline from SIMILE. So far I have gotten my timeline to work if the data comes from a XML file.

Timeline.loadXML("example.xml", function(xml, url) { eventSource.loadXML(xml, url); });

However, I want to get data from a JSON file instead of an XML file.

Thanks a lot for your help. PS: I am still a rookie in javascript

Julio Diaz
  • 9,067
  • 19
  • 55
  • 70

1 Answers1

1

I just figured this out for a project this weekend by checking out the source of the example Cubism timeline on the wiki.

What you see in that sourcecode is the following:

tl.loadJSON("cubism.js?"+ (new Date().getTime()), function(json, url) {
  eventSource.loadJSON(json, url);
});

There are a few things to note about this. First, tl is your Timeline.create(...) object. Second, the ? and new Date stuff appended to the JSON filename ensure a unique URL on each call to prevent JSON caching.

joem
  • 26
  • 1
  • 1
    It is confusing the way SIMLE's folks advise to use JSON, but they dont give a clear example. – Julio Diaz Mar 14 '11 at 03:49
  • 1
    Were you able to understand the answer I provided? For me, it was a drop-in replacement for the XML handling code you provided. – joem Mar 17 '11 at 04:53
  • Can you open up a javascript console on the page an see if there are any error messages? (In Safari/Chrome, you need to open up Web Inspector and then go to the Console tab. In Firefox, you can check errors in the Error Console, but installing Firebug gives you a nice full console.) – joem Mar 20 '11 at 20:00