The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> JavaScript Development
|
Javascript not loading XML?
Discuss Javascript not loading XML? in the JavaScript Development forum on Dev Shed. Javascript not loading XML? JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

January 8th, 2013, 03:51 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 13
Time spent in forums: 3 h 30 m
Reputation 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?
|

January 8th, 2013, 04:07 PM
|
 |
JavaScript is not spelt java
|
|
Join Date: Feb 2011
Location: Landan, England
|
|
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
|

January 8th, 2013, 04:25 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 13
Time spent in forums: 3 h 30 m
Reputation Power: 0
|
|
|
Ahhh, okay, it's working in Safari...
Anything I can do to fix this?
|

January 8th, 2013, 04:28 PM
|
 |
JavaScript is not spelt java
|
|
Join Date: Feb 2011
Location: Landan, England
|
|
Quote: | 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
|

January 8th, 2013, 05:14 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 13
Time spent in forums: 3 h 30 m
Reputation 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.
|

January 8th, 2013, 06:21 PM
|
 |
JavaScript is not spelt java
|
|
Join Date: Feb 2011
Location: Landan, England
|
|
Quote: | 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.
|

January 9th, 2013, 09:03 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 13
Time spent in forums: 3 h 30 m
Reputation 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?
|

January 9th, 2013, 09:23 AM
|
 |
JavaScript is not spelt java
|
|
Join Date: Feb 2011
Location: Landan, England
|
|
|
I don't touch Joomla. You might be better of posting on a Joomla forum.
|

January 9th, 2013, 09:58 AM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 13
Time spent in forums: 3 h 30 m
Reputation Power: 0
|
|
|
Yeah, I wish I didn't touch Joomla either. =/
Thanks for your help.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|