Created
April 27, 2015 20:30
-
-
Save benkutil/7b5a20222a621125c3b5 to your computer and use it in GitHub Desktop.
pseudo code for loading multiple ajax items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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