How to show a loading gif mean while a submit form is being executed JQuery

前端 未结 5 391
甜味超标
甜味超标 2020-12-16 00:59

I\'m trying to show a simple spinner gif meanwhile a submit is being executed (it takes a bit because I have to establish some communications with providers via web services

5条回答
  •  清酒与你
    2020-12-16 01:37

    Have you tried loading the image on document ready, only having it hidden. Then display it in your function? This way, the image is already loaded and spinning.

    $(document).ready(function() {
        $("body").prepend('');
        $("body").prepend("");
    });
    
    $('#gds_form').submit(function() {
        var pass = true;
        //some validations
    
        if(pass == false){
            return false;
        }
        $("#overlay, #PleaseWait").show();
    
        return true;
    });
    

提交回复
热议问题