Facebook style Image Loading

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
jishcem
Forum Newbie
Posts: 12
Joined: Tue Nov 10, 2009 11:48 pm

Facebook style Image Loading

Post by jishcem »

Hi,

I am not sure whether I should post this topic in Javascript or PHP, I want to load images in the facebook way.

That is while an image is loading up in facebook, it shows its unique loading gif image. I was wondering how could we do that...I tried the z index way and failed miserably...I was wondering should I use AJAX in this case. Or is there any simple method?
ajith_rock
Forum Newbie
Posts: 11
Joined: Wed Sep 08, 2010 2:37 am

Re: Facebook style Image Loading

Post by ajith_rock »

Yes... I use AJAX for doing this... I typically have the image loading happen when the xmlHttp object is in the state "0","1","2", or "3".

if (xmlHttp.readyState == 1 || xmlHttp.readyState == 2 || xmlHttp.readyState == 3 || xmlHttp.readyState == 0)
{
// Load the "loading image" here.
// Example :
// document.getElementById("status_msg_reg").innerHTML="images/loading_img.gif";
}
else if(xmlHttp.readyState == 4)
{
// Do the response processing here
}

Cheers,

--
Ajith
Post Reply