I am having a page where I get feed from youtube and then display this on this page. There are 3 rows each of 4 images each corresponding to youtube videos. I get these image links from youtube feed itself.
What I want to achieve is while rendering these images, i want to fetch image from youtube for one row at a time. If the images load is not completed, I would want to wait until next row images are fetched.
Can someone guide me how this can de done? I read stuff about jquery deferred objects and callbacks, but since am not strong on jquery/js not able to really crack this one. The js executes asynchronously and therefore all image requests go one after another and am not able to make js wait until images for each row are completely rendered before next row is sent.
I have a for loop currently and diaply images as follows:
$j("#thumbnail_image_"+i).css({'background-image':'url('+cdnPath+')'});
myImage[i].src = cdnPath;