I can’t believe that I’m having an issue with this. My setTimeout is:
setTimeout(function(){showContent(entries, 0);}, 500);
I also tried:
(function(entries, index){
clear_show_content = setTimeout(function(){
showContent(entries, index);
}, 500);
})(entries, 0);
and in showContent(entries, index) index is undefined. Please tell me I’m just missing something obvious here.
EDIT: This code is causing so many problems tonight 🙂
var clear_show_content;
function showContent(json){
var entries = json;
$('#content').html('');
if(checkIfNoneEntered(entries))
$('#content').append('<div class="entry">No Alumni Entered Yet!</div>');
else if(checkIfNoMatches(entries))
$('#content').append('<div class="entry">No Matches Found!</div>');
else if(checkIfError(entries))
$('#content').append('<div class="entry">There was an error!</div>');
else {
clearTimeout(clear_show_content);
$('#content').append('<table border="2" id="content_table" width="50%">');
var filler = '<img width="1" height="1" />';
clear_show_content = setTimeout((function(){showContent(entries, 0);}),
500);
}
}
function showContent(entries, index){
if(index < 0)
return;
stop = index + 10 > entries.alumnus.length ? entries.alumnus.length : 10;
start = new Date();
for(allIndex = index; allIndex < stop; allIndex++){
}//This is where it becomes proprietary, but I highly doubt the issue is after here
EDIT 2: Here’s a jsFiddle of the issue. It’s not working on my browser (Chrome 16) and I don’t currently have access to any other browser. I don’t think that’s the issue though, as I’ve written code like this hundreds of times. http://jsfiddle.net/eygraber/NduqY/1/
You’re defining your
showContentfunction twice…