If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

If you want a little eyecandy for the ajax function relace it with (web2py_ajax.html)

function ajax(u,s,t) { 
  $("#"+t).html('{{=IMG(_src=URL(request.application,'static','loading.gif' ,_alt='loading')}}'); 
  var query=""; 
  for(i=0; i<s.length; i++) { 
         if(i>0) query=query+"&"; 
     query=query+encodeURIComponent(s[i])+"="+encodeURIComponent 
(document.getElementById(s[i]).value); 
  } 
  jQuery.ajax({type: "POST", url: u, data: query, success: function 
(msg) { if(t==':eval') eval(msg); else document.getElementById 
(t).innerHTML=msg; } }); 

}

and put a loading.gif in the static folder you can find loading images at http://www.freeiconsdownload.com/Free_Downloads.asp?id=585

Related slices

Comments (3)

  • Login to post



  • 0
    carlosarmenta 9 years ago

    I have an easiest way to do this:

    LOAD( url=URL(a='app', c='controller', f='foo', user_signature=True), ajax=True, content= IMG(_src=URL(request.application,'static','images/loader.gif'))

    Explanation:

    The full signature of the LOAD helper is the following:

    LOAD(c=None, f='index', args=[], vars={},
         extension=None, target=None,
         ajax=False, ajax_trap=False,
         url=None,user_signature=False,
         timeout=None, times=1,
         content='loading...',**attr):

     

    replies (1)

  • 0
    select 13 years ago
    well the only thing that is changed here is that i added $("#"+t).html('{{=IMG(_src=URL(request.application,'static','loading.gif' ,_alt='loading')}}'); just under the function header (i changed the code to use jquery functions now) all it does is to set the content of t (the target div) to the loading image, once the proper content is there it will replace everything in the t div

  • 0
    iiit123 13 years ago
    It does not work for me. Can u plzz explain a bit more. i repalced the ajax function in web2py_ajax.html with this function.

Hosting graciously provided by:
Python Anywhere