Using Timeline with JSON is quite easy to do.
Timeline provides methods for reading data from a JSON source.

You don't need to (and shouldn't have to) store your json output in a global 
variable. 

Set up your timeline then load your data:
  tl = Timeline.create(document.getElementById("tl"), bandInfos);
                        
  tl.loadJSON("timeline/json_output.json", function(data, url) {
    eventSource.loadJSON(data, url);
  });

eventSource is the eventSource object that you passed in your constructor for 
the bands. 

You can use jQuery's ajax functions to get the timeline data yourself, and pass 
the result to the loadJSON method of your eventSource.

You need to make sure that you load your json data *after* you have created 
your timeline. Or rather, make sure you call eventSource.loadJSON after you've 
constructed your timeline.

--Mike Nosal


On Sep 7, 2012, at 5:00 AM, Maurizio Liberato wrote:

> Hi all, firstly let me congratulate with Smile for the Timeline widget, think 
> it's great!
> 
> I have a site on where I'm implementing the timeline but I need to use a json 
> service as data source. How do I do it?
> I'm not great at javascript so I couldn't find a way to store the entire Json 
> output (which is correcly formatted accordingly) in a global variable.
> 
> That's what I've tried but I'm stuck on how to store in the variable the 
> entire output and not just one entry:
> 
> var timeline_data; //at global scope
> $.ajax({ 
>         type: 'GET', 
>         url: '/timeline/json_output.json', 
>         dataType: 'json', 
>         timeout: 10000, 
>         crossDomain: true, 
>         success: function(result) {
>             timeline_data = result;
>         }
> });
> Now I don't know how to use the variable timeline_data. Think it's an array 
> object. The following code doesn't work (of course):
> 
> eventSource1.loadJSON(timeline_data, url);
> 
> So I don't know how to proceed further. Any help much appreciated.
> 
> Thanks in advance
> 

-- 
You received this message because you are subscribed to the Google Groups 
"SIMILE Widgets" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/simile-widgets?hl=en.

Reply via email to