I hope this makes sense...
I have a page that loads the same external file 1-12 times depending on the usage. The larger load times takes up to a full minute to load the page so I'm trying to load each file via ajax, but using a loop to load the files completely hangs the server.
Here's the code I'm using so far:
function getSchedule(startday,scheduleID,scheduleView){
$.ajax({
type: 'POST',
url: siteURL+'/includes/schedule-'+scheduleView,
data: {startday:startday,scheduleID:scheduleID},
success: function(data){
$('.scheduleHolder'+scheduleID).html(data).removeClass('loading');
}
});
}
var loadSchedules = [];
var startday = $('#the_start_day').text();
var totalSchedules = $('.scheduleHolder').length;
var i = 0;
$('.scheduleHolder').each(function(){
var currentHolder = $(this);
var scheduleView = currentHolder.attr('rel');
var scheduleID = currentHolder.attr('id');
loadSchedules.push(getSchedule(startday,scheduleID,scheduleView));
if (totalSchedules==i) {
$.when.apply($, loadSchedules);
}
i++;
});
Each file should only take 2-5 seconds to load when it's loading individually, so I was really hoping the total load time could go from 60 seconds to 10 or so.
So, my question is how can I load the same file multiple times and at the same time without killing the server? Does that make sense?