Hello I am doing a Horizontal scrolling website like: http://vanityclaire.com/
However, rather than having one large HTML file, after the load of the homepage, I am ajaxing in the children of home, using jQuery .load().
At present I for-each div and ajax in ithe url that sits in the title. But the AJAX returns out of order, and as I add more pages don't fancy spanging the server with 30+ http:// requests.
How do I synchronously do the AJAX calls, i.e. wait for the first to comeback before a request another, or even send two at a time.
I have been scouring, and cannot figure out what I need.
This is my HTML:
<div id="mainLayout" class="fullwidth scrollArea">
<div class="scrollItems">
<div id="page-1" class="scrollItem" title="/">
<div>HOME PAGE CONTENT</div>
</div>
<div id="page-2" class="scrollItem" title="/Page2.html">
<div class="loading"> </div>
</div>
<div id="page-3" class="scrollItem" title="/Page3.html">
<div class="loading"> </div>
</div>
<div id="page-4" class="scrollItem" title="/Page4.html">
<div class="loading"> </div>
</div>
<div id="page-5" class="scrollItem" title="/Page5.html">
<div class="loading"> </div>
</div>
</div>
</div>
And my JS:
function s_loadingInitialPages() {
var loadingItems = new Array();
$(".scrollArea .scrollItem").each(function () {
if ($(this).attr('title') != '/') {
var oDelem = $(this);
loadingItems.push(oDelem);
//alert('test');
}
});
for (i = 0; i < loadingItems.length; i++) {
// title attribute is the URL to get
var ajaxURL = loadingItems[i].attr("title") + '?ajaxPageContent=';
$(loadingItems[i]).load(ajaxURL);
}
}
Is there a plugin I can just keep adding functions to a queue, and let that handle it?