Rather than locally packaging an xml/text file within the SCORM object, we are hoping to maintain the text/xml in a global location on a website. Our goal is to be able to change the content/value of the xml/text file on the website instead of changing it locally and then having to re-send SCORM content to our customers.
Is it possible to point to an XML file on a website (for example):
xhttp.onerror = function() { // only triggers if the request couldn't be made at all alert(`Network Error`); };
function getValues(xml) { var player = GetPlayer(); var xmlDoc = xml.responseXML; var x = xmlDoc.getElementsByTagName('db'); player.SetVar("Value1", x[0].getAttribute('value')); player.SetVar("Value2", x[1].getAttribute('value')); player.SetVar("Value3", x[2].getAttribute('value')); }
1 Reply
If it helps, I am adapting some Javascript that works for a local file but it does not seem to work:
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
getValues(this);
}
};
let url1 = new URL('https://www.myserver.com/values.xml');
alert (url1);
xhttp.open("GET", url1, true);
xhttp.send();
xhttp.onload = function() {
alert(`Loaded: ${xhttp.status} ${xhttp.response}`);
};
xhttp.onerror = function() { // only triggers if the request couldn't be made at all
alert(`Network Error`);
};
function getValues(xml) {
var player = GetPlayer();
var xmlDoc = xml.responseXML;
var x = xmlDoc.getElementsByTagName('db');
player.SetVar("Value1", x[0].getAttribute('value'));
player.SetVar("Value2", x[1].getAttribute('value'));
player.SetVar("Value3", x[2].getAttribute('value'));
}