Hi Vineet,

as juanduke has suggested, I use the following jquery function (I put it in 
web2py_ayax.js) instead of standard w2p ajax function to show a loading 
image:

function web2py_polling(u,s,t){
$('#'+t).html('<div id="loading_gif_container"><img 
src="/static/images/loading.gif" alt="loading..." height="64" width="64" 
/></div>');
ajax(u,s,t);
}

Of course you can set some css rules to custom div#loading_gif_container.

How to use:
I insert at the bottom of the view :

<script  type="text/javascript" charset="utf-8">
//<!--
jQuery(document).ready(function(){
web2py_polling('get_output',[args],'output_target');
//-->
</script>

### controller ###

def get_output():
the_output = "I'm the output"
return the_output


You could also use a standard ajax call to a function that returns 
web2py_polling function that, optionally, calls another action.

For example:

### in the view ###

<script  type="text/javascript" charset="utf-8">
//<!--
jQuery(document).ready(function(){
ajax('get_output',[args],':eval');
//-->
</script>

### controller ###

def get_output():
# make evaluation 
return "web2py_polling('another_action',[args],'output_target');"

def another_action():
the_output = "I'm the output"
return the_output


Ciao.

Paolo

Reply via email to