SIMILE's timeline and google calendar using JSON instead of XML
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 javascri开发者_如何学Gopt
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.
精彩评论