Page 1 of 1

Facebook style Image Loading

Posted: Fri Sep 10, 2010 12:18 pm
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?

Re: Facebook style Image Loading

Posted: Tue Sep 14, 2010 7:00 pm
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