#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    13
    Rep Power
    0

    Javascript not loading XML?


    Code:
    <body onload="onLoad();" onresize="onResize();">
         <div id="my-timeline" style="height: 150px; border: 1px solid #aaa"></div>
    		<noscript>
    			This page uses Javascript to show you a Timeline. Please enable Javascript in your browser to see the full page. Thank you.
    		</noscript>
            
            <script>
    			var tl;
    			 function onLoad() {
    			   var eventSource = new Timeline.DefaultEventSource();
    			   var bandInfos = [
    				 Timeline.createBandInfo({
    					 eventSource:    eventSource,
    					 date:           "Jun 28 2006 00:00:00 GMT",
    					 width:          "70%", 
    					 intervalUnit:   Timeline.DateTime.MONTH, 
    					 intervalPixels: 100
    				 }),
    				 Timeline.createBandInfo({
    					 eventSource:    eventSource,
    					 date:           "Jun 28 2006 00:00:00 GMT",
    					 width:          "30%", 
    					 intervalUnit:   Timeline.DateTime.YEAR, 
    					 intervalPixels: 200
    				 })
    			   ];
    			   bandInfos[1].syncWith = 0;
    			   bandInfos[1].highlight = true;
    			   
    			   tl = Timeline.create(document.getElementById("my-timeline"), bandInfos);
    			   Timeline.loadXML("example1.xml", function(xml, url) { eventSource.loadXML(xml, url); });
    			 }
    			
    			 var resizeTimerID = null;
    			 function onResize() {
    				 if (resizeTimerID == null) {
    					 resizeTimerID = window.setTimeout(function() {
    						 resizeTimerID = null;
    						 tl.layout();
    					 }, 500);
    				 }
    			 }
    		</script>
    </body>
    I'm working from here: http://simile-widgets.org/wiki/Timeline_GettingStarted


    When I preview this in Chrome, it asks if I want to translate it because it's in Icelandic... I was like...okay...so I hit yes. That fails, however, and asks if I'd like to try again...

    The info in the XML file isn't being loaded either. All I see is a timeline that I can at least scroll through. I'm attempting to test with the exact same file provided before I strike out on my own so I'm not sure what went wrong.

    I saved my HTML file in the same folder as the example1.xml file to be sure that it was viewable. Do I need to upload this on a server to test with XML or did I blatantly screw up somewhere?
  2. #2
  3. JavaScript is not spelt java
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2011
    Location
    Landan, England
    Posts
    743
    Rep Power
    165
    Have you correctly attached the Timelines API?

    Code:
    <script src="http://api.simile-widgets.org/timeline/2.3.1/timeline-api.js?bundle=true" type="text/javascript"></script>
    Are there error messages in your browsers' console?

    Have you tried it in different browsers?

    Is your XML correctly formed?
    "The mysql extension is deprecated as of PHP 5.5.0, and is not recommended for writing new code as it will be removed in the future. Instead, either the mysqli or PDO_MySQL extension should be used." the docs
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    13
    Rep Power
    0
    Ahhh, okay, it's working in Safari...

    Anything I can do to fix this?
  6. #4
  7. JavaScript is not spelt java
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2011
    Location
    Landan, England
    Posts
    743
    Rep Power
    165
    Originally Posted by Sonfang
    Ahhh, okay, it's working in Safari...

    Anything I can do to fix this?
    Try creating another shortcut to Chrome and add the following to the command-line:

    --allow-file-access-from-files
    "The mysql extension is deprecated as of PHP 5.5.0, and is not recommended for writing new code as it will be removed in the future. Instead, either the mysqli or PDO_MySQL extension should be used." the docs
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    13
    Rep Power
    0
    Should it be okay when the site goes live? I just want to be sure certain users won't be experiencing browser issues.
  10. #6
  11. JavaScript is not spelt java
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2011
    Location
    Landan, England
    Posts
    743
    Rep Power
    165
    Originally Posted by Sonfang
    Should it be okay when the site goes live? I just want to be sure certain users won't be experiencing browser issues.
    Should be. The setting I mentioned is only necessary when testing locally.
    "The mysql extension is deprecated as of PHP 5.5.0, and is not recommended for writing new code as it will be removed in the future. Instead, either the mysqli or PDO_MySQL extension should be used." the docs
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    13
    Rep Power
    0
    Now that I know it's working, I'm having an issue with Joomla in particular...

    All we see when we upload this stuff is an empty box. We put the XML in the same location as the HTML, we took out the onload part because Joomla seems to swallow it up, and we looked up how to use this part:

    Code:
    <script src="http://api.simile-widgets.org/timeline/2.3.1/timeline-api.js?bundle=true" type="text/javascript"></script>
    ...in Joomla speak but it's still just a blank box. We used this format:

    Code:
    <source lang="php">
    $doc =& JFactory::getDocument();
    $doc->addScript( “http://www.example.com/js/myscript.js” );
    </source>

    So now we're looking at plugins instead but still...is this just not usable in Joomla or am I missing something obvious?
  14. #8
  15. JavaScript is not spelt java
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2011
    Location
    Landan, England
    Posts
    743
    Rep Power
    165
    I don't touch Joomla. You might be better of posting on a Joomla forum.
    "The mysql extension is deprecated as of PHP 5.5.0, and is not recommended for writing new code as it will be removed in the future. Instead, either the mysqli or PDO_MySQL extension should be used." the docs
  16. #9
  17. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    13
    Rep Power
    0
    Yeah, I wish I didn't touch Joomla either. =/

    Thanks for your help.

IMN logo majestic logo threadwatch logo seochat tools logo