Skip to content

Instantly share code, notes, and snippets.

@benkutil
Created April 27, 2015 20:30
Show Gist options
  • Save benkutil/7b5a20222a621125c3b5 to your computer and use it in GitHub Desktop.
Save benkutil/7b5a20222a621125c3b5 to your computer and use it in GitHub Desktop.
pseudo code for loading multiple ajax items
infoLoaded = function infoLoadedF () {
// insert video
var videoHTML = '<iframe id="ytplayer" type="text/html" width="640" height="390"
src="http://www.youtube.com/embed/' + SITE.videoID + '?autoplay=1&origin=http://example.com"
frameborder="0"/>';
document.getElementById('youtube-video').innerHTML(videoHTML);
// insert script
var scriptText = '';
for (var i = 0; i < scriptArray.length; i++) {
var scriptText += '[ ' + i +' ]' + scriptArray[i] + '<br>';
};
document.getElementById('script-area').innerHTML(scriptText);
}
infoError = function infoErrorF () {
}
getInfo = function getInfoF () {
var getHanta,
getImage,
getVideo;
getHanta = $.ajax();
getImage = $.ajax();
getVideo = $.ajax();
$.when( getHanta, getImage, getVideo ).then(infoLoaded, infoError);
}
// HTML
<div id="content">
<img id="loader" src="spinner.gif" alt="">
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment