views:

120

answers:

1

Hi, i have the following code:

$("#forma_mod_uid").livequery( function (){
       $("#forma_mod_uid").ajaxForm({
                beforeSubmit: mcargando("#cargando2"),
                target:'#mod_2',
                success: ocargando("#cargando2")
       })
});

the mcargando passes the div wich will contain a spinner img, and then on success ocragando will hide that div, problem is that beforeSubmit is firing beforeSubmit on document ready

function mcargando(id_div){
    if (id_div==null){ var id_div="#cargando";}
    $(id_div).livequery(function (){$(id_div).show();});
}
+3  A: 
beforeSubmit: mcargando("#cargando2"),

Should be:

beforeSubmit: function() { mcargando("#cargando2") },

And

success: ocargando("#cargando2")

Should be:

success: function() { ocargando("#cargando2") }

As you have it right now, you are calling the functions. The only way you could use the code you have there without calling the function is if you did beforeSubmit: mcargando, but since you need to pass a variable to the function just wrap the call in a function to be able to do it and you should be fine.

Paolo Bergantino
Thanks it worked!