Magento – load ajax loader image after clicking save button

form-validation

I am using magento 1.9 version. After clicking save or any button then I want to show progress by ajax loader. I found a div having ID "loading-mask". If i will change its style display:none to block then it all working fine. But I want to change this after validation pass. Where should I can place this condition for proper result ?

document.getElementById("loading-mask").style.display="Block";

Best Answer

You can show the imagen when the form is submitted:

$j(function() {
     $j('form').submit( function() {
         alert("Something"); //do something else here
         //in your case
         $j("#loading-mask").show();
         return true;
     });
});