views:

382

answers:

2

I am working to develop a facebook application and am running into a small snag. When making a ajax call I want to let the user know that the application is loading.

My confusion is that others say facebook does not allow animated gifs however the above application has an animated gif. I scoured through their source code to no avail. Any thoughts on how to get animated gifs to play in a facebook application would be great.

<script type="text/javascript">
function search_ajax()
{
    document.getElementById('loading').setStyle('display', 'block');
    var ajax = new Ajax();
    ajax.responseType = Ajax.FBML;
    ajax.ondone = function(data) {
        document.getElementById('search_results').setInnerFBML(data);
        document.getElementById('loading').setStyle('display', 'none');
    }
    var queryParams = { "VSearchMake" : document.getElementById('VSearchMake').getValue(),
    "VSearchModel" : document.getElementById('VSearchModel').getValue(),
    "VSearchYear" : document.getElementById('VSearchYear').getValue(),
    "VSearchPrice" : document.getElementById('VSearchPrice').getValue(),
    "ShowNewUsed" : document.getElementById('ShowNewUsed').getValue()   };
    ajax.post('http://domainname/facebook/results.cfm', queryParams);
}

</script>

<img src="http://domainname/images/loading.gif" id="loading" style="display:none;" />
+1  A: 

You mean the animated blue bars? I'd bet that's not an animated gif, but some JavaScript stuff going on. Given that I've seen it on many sites, I'd look for a corresponding JS function in the Facebook API. Sorry for not giving a more complete answer, but maybe this points you into the right direction.

Nicolas78
That was my thought, I did right click and view the image though and saw that it was an animated gif. I will look into a function to swap through images. I just hate not being able to figure things out when I know its possible... I guess thats one of the things that makes the job fun.
Patcouch22
[It is definitely an animated GIF](http://leads.socialups.com/static/images/fbinventory/ajax_loader.gif).
alex
oops ok. so did you check the code in http://leads.socialups.com/static/js/ ? should be in there (I know you said you checked their code, just not sure if you checked the libraries as well)
Nicolas78
No luck yet in their code... I'll have to go through it again with a finer comb maybe.
Patcouch22
+1  A: 

I have used animated gifs in my apps. Basically you setup the gif in image tag and hide it initially on page load like this:

<img src="http://example.com/images/mygif.gif" style="display:none;" id="wait">

And when the ajax request is sent, you unhide the image:

document.getElementById('wait').setStyle('display', 'block');

And once you get the success respones from ajax, you hide it again:

document.getElementById('wait').setStyle('display', 'none');

Update:

You are not hiding it back, use this code instead:

ajax.ondone = function(data) {
    document.getElementById('search_results').setInnerFBML(data);
    document.getElementById('loading').setStyle('display', 'none');
}
Sarfraz
It is still coming up not animated, any thoughts? Edited my question with my code in it.
Patcouch22
@Patcouch22: Please post your ajax code as well as html for the gif image that you have put in the page.
Sarfraz
@Patcouch22: See my updated answer please.
Sarfraz
fixed that.. still not animating the gif.
Patcouch22
@Patcouch22: Can you point me to your app
Sarfraz
@Patcouch22: This is a fan page not an application not that fan page has limitations. Also the inventory page is not opening, there could be some error. I am not sure animated gifs worn on fan pages as facebook offers limited functionality for them.
Sarfraz
Alright... I am new to the facebook api, was not the other page I gave as an example also a fan page? Or did they use a different setup?
Patcouch22
@Patcouch22: Does your ajax request go successful and you get the response?
Sarfraz
yes. are you unable to pull up the inventory tab on the page?
Patcouch22
@Patcouch22: Nope it is not opening.
Sarfraz
Any luck loading it now? What OS/Browser are you using?
Patcouch22
yes it open now
Sarfraz