[Solved] Ajax each not looping in IE
I am retrieving and displaying XML data from a file. I am adding a break between each record in the each code. It works fine in Firefox, Chrome, and Safari. In IE, it only lists one record. It doesn't appear to be looping through the results.
Here's the xml...
-
<playlist>
<song>
<songtitle>10 Good Reasons</songtitle>
<artist>Hello Kelly</artist>
<duration>02:59</duration>
<playtime>12:00:20 AM</playtime>
<link></link>
<mmscript></mmscript>
<phone></phone>
<linktext></linktext>
</song>
<song>
<songtitle>Free to Be Me</songtitle>
<artist>Francesca Battistelli</artist>
<duration>03:26</duration>
<playtime>12:03:29 AM</playtime>
<link></link>
<mscript></mscript>
<phone></phone>
<linktext></linktext>
</song>
<song>
<songtitle>Breathe</songtitle>
<artist>Jeremy Camp</artist>
<duration>02:49</duration>
<playtime>12:07:05 AM</playtime>
<link></link>
<mscript></mscript>
<phone></phone>
<linktext></linktext>
</song>
</playlist>
Her's the jquery code...
-
// Start function when DOM has completely loaded
$(document).ready(function(){
getdata()
});
function getdata(){
// variable to alter the url so IE won't cache the data
nocache = Math.random();
$.ajax({
url: 'SeePlaylist.xml' + "?nocache=" + nocache,
type: 'GET',
dataType: 'xml',
timeout: 1000,
error: function(){
alert('Error loading XML document');
},
success: function(xml){
$(xml).find('song').each(function(){
var SongTitle = $(this).find('songtitle').text();
var Artist = $(this).find('artist').text();
document.write(SongTitle + " by " + Artist + "<br>");
});
}
}); //close $.ajax(
}
In the non IE browsers all the records are displayed. In IE, the first record is displayed and no more. No errors.