I am building a client-side application where I send requests to YouTube API, Instagram API, Tumblr API. When those requests are processed, an appropriate callback function is executed.
The problem is YouTube always finishes first, appends data to HTML via underscore.js templates. Then a few seconds later Instagram and Tumblr results are also appended.
My app.js file contains 3 separate plain javascript functions:
function showYoutube() { ... }
function showInstagram() { ... }
function showTumblr() { ... }
How could I display a simple "Loading..." message until all 3 callback functions have been successfully completed?
Update:
Still looking for a possible solution. Please note I do not have back-end service, thus I am limited to JSONP API requests only.
My API call is located in index.html and looks something like this:
<script
type="text/javascript"
src="http://gdata.youtube.com/feeds/users/GoogleDevelopers/uploads?v=2&alt=json-in-script&format=5&callback=showMyVideos">
</script>
So, function showMyVideos()
has to be in the global scope. I've tried implementing jQuery Deffered and Async.js Parallel with no luck.