I am working on creating a web application that will be displayed on a local intranet site
NB I am using IE11
It takes information from an XML file and cycles through it, displaying each section in turn.
I have had to use an old version of JQuery in order to make this work on the system it'll be running on, so I am using 1.12.4.
My problem is that the page pulls in the information in the first instance, but after that it does nothing. A quick check in the debugging console tells me that the page is Unable to get property 'childNodes' of undefined or null reference - which seems strange to me as it works in the first instance.
If I run the page in compatibility view, the script works properly, but then this destroys all of my styling etc.
Is there a way to fix this or am I going to have to deal with an awful compatibility view styled page?
My code is below
HTML
<div id="MainNews">
<div class="panel panel-default" id="MainNewsStory">
<h1 id="StoryHeadline"></h1>
<p id="StoryBody"></p>
</div>
<img id="StoryImage" src=""/>
</div>
XML
<NewsArticle>
<Story>
<StoryHeadline>This is the headline of the first news story!</StoryHeadline>
<StoryBody>This is the body of the first news story. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id nunc ex.</StoryBody>
<StoryImage>Images\ImageOne.png</StoryImage>
</Story>
<Story>
<StoryHeadline>This is the second headline! It accompanies the second story</StoryHeadline>
<StoryBody>This is the body of the second news story. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id nunc ex.</StoryBody>
<StoryImage>Images\ImageTwo.png</StoryImage>
</Story>
<Story>
<StoryHeadline>This is the third headline now!</StoryHeadline>
<StoryBody>This is the body of the third news story. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id nunc ex.</StoryBody>
<StoryImage>Images\ImageThree.png</StoryImage>
</Story>
JavaScript
$(function(){
$.ajax({
type: "GET",
url: "SetScreen.xml",
dataType: "xml",
success: parseXml
});
function parseXml(xml) {
//--Fill the content in to the main news story START--//
var storyCount = 0;
var xStories = xml.getElementsByTagName("StoryHeadline");
var xStoryBody = xml.getElementsByTagName("StoryBody");
var xStoryImage = xml.getElementsByTagName("StoryImage")
var maxStories = xStories.length;
function fillStory(){
$('#StoryHeadline').html(xStories[(storyCount) % maxStories].childNodes[0].nodeValue);
$('#StoryBody').html(xStoryBody[(storyCount) % maxStories].childNodes[0].nodeValue);
$('#StoryImage').prop("src", xStoryImage[(storyCount++) % maxStories].childNodes[0].nodeValue);
}
//--Fill the content in to the main news story END--//
fillStory();
var storyTimer = setInterval(fillStory, 2000);
}
});
Any help would be very much appreciated.