5

I created a SIMILE Timeline that uses an XML file as data source which is created by a method when an aspx command is invoked. The problem is that when the XML file is updated the Timeline isn't updated and shows the data of the first load. The data is only refreshed when I close the browser and open again the Web Application with the Timeline. Even if I go to another page of my Web Application and then come back to the page with the Timeline the data showed stills the same. I already confirmed that the XML file is created/updated before the script that creates the Timeline be invoked and I also tried some tricks like force the PageLoad(), do a Response.Redirect() and don't use cache. My function onLoad() is similiar to the original provided by simile-widget. Code:

      <head>
      ...
      <meta http-equiv="pragma" content="no-cache" />
      <META HTTP-EQUIV="Expires" CONTENT="-1">
      ...
      var tl;
      function onLoad() {
        $(document).ready(function() {
            var eventSource1 = new Timeline.DefaultEventSource(0);
            var theme1 = Timeline.ClassicTheme.create();
            theme1.timeline_start = new Date(Date.UTC(2010, 0, 1));
            theme1.timeline_stop = new Date(Date.UTC(2014, 0, 1));
            var d = theme1.timeline_start;
            var bandInfos = [
            Timeline.createBandInfo({ ... }),
            Timeline.createBandInfo({ ... })
       ];
            bandInfos[1].syncWith = 0;
            bandInfos[1].highlight = true;

            // create the Timeline
            tl = Timeline.create(document.getElementById("tl"), bandInfos);
            var url = '.';

            // references in the data
            tl.loadXML("batch_data.xml", function(xml, url) 
            {eventSource1.loadXML(xml, url); });
            tl.finishedEventLoading();
        });
    }
    ...
    </head>

    <body onload="onLoad();" onresize="onResize();">
      <form id="form1" runat="server">
                <div id="tl" runat="server">
                ...
                </div>
      </form>   
    </body>

Thanks!

Bruno V
  • 51
  • 1
  • Not sure why you wrap the jquery document load inside a function that gets invoked on body load. – Lin Apr 02 '14 at 02:08

1 Answers1

0

The first clue you wrap your javascript code onLoad function. Try to create a button to update the page using the function onClick event. If you like to upgrade to a period of time you can use the JavaScript timing event.

Here is a link to a documentation of a timing event examples

I put the example this simple as posible:

 setInterval(function(){alert("Hello")},3000); 

and this is the sintax

window.setInterval("javascript function",milliseconds);
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Michael Dunlap Apr 07 '14 at 16:57
  • I put the example this simple as posible: setInterval(function(){alert("Hello")},3000); and this is the sintax window.setInterval("javascript function",milliseconds); – Juan Jose Gazzola Apr 07 '14 at 17:06