I have this piece of code, it works in all browsers, except for Safari:
// Create a connection to the file.
var Connect = new XMLHttpRequest();
// Define which file to open and
// send the request.
Connect.open("GET", "<?php echo $fileName;?>", false);
Connect.setRequestHeader("Content-Type", "text/xml");
Connect.setRequestHeader("Cache-Control", "no-cache");
Connect.send();
// Place the response in an XML document.
var TheDocument = Connect.responseXML;
// Place the root node in an element.
var questions = TheDocument.childNodes[0];
// Retrieve each customer in turn.
for (var i = 0; i < 1; i++) {
console.log(i);
console.log("fake var");
var question = questions.children[0];
console.log(question);
}
Variable $filename is the php link to the XML file i'm reading. I have the following issue, the code runs into the For loop, i can log var "i", and "fake var". But once i define var question as questions.children[0], the code stops. I cant log the question var in safari.
Any ideas? ( Feedback also welcome, still learning javascript/xml )
Example of my XML:
<?xml version='1.0' encoding="UTF-8" ?>
<Beantwoordt_kritiek id="1" admin="Jan Hut" categorie="Omgaan met elkaar" winswf="images/Kado (1).jpg">
<gebruikers_vraag1>
<vraag><![CDATA[Sleep de puzzelstukken naar het juiste vakje.]]></vraag>
<s_vraag><![CDATA[sounds/puzzel.mp3]]></s_vraag>
<thumb1><![CDATA[images/527puzzel1_1.jpg]]></thumb1>
<thumb2><![CDATA[images/527puzzel1_2.jpg]]></thumb2>
<thumb3><![CDATA[images/527puzzel1_3.jpg]]></thumb3>
<thumb4><![CDATA[images/527puzzel1_4.jpg]]></thumb4>
<vraagFoto><![CDATA[images/527puzzel1.jpg]]></vraagFoto>
</gebruikers_vraag1>
</Beantwoordt_kritiek>