Insert xml file into div - click event
I have here a gaggle of numbered XML documents.
Made a loop to go through every number and append a link to the file to a list.
Click event works.
All within doesn't.
-
$(document).ready(function () {
var allFiles = new Array();
for (var i=0; i<=4000; i+=1000) (function() {
var linkName = i + ".xml";
alert(linkName);
$.get(linkName, function() {
allFiles.push(linkName);
})
})(i);
$.each(allFiles, function() {
$('#navlist').append('<a class="navlink">' + this + "</a>");
alert(this);
$(".navlink").click( function() {
var $this = $(this);
var $a = $this.closest('a');
alert($a);
$("#story").load($a.closest());
});
});
});