开发者

jquery loading animation with php form that submits back to itself

I have a PHP file that contains a form and which submits back to itself. Is there any way to show a loading animation after the form is submitted and run u开发者_运维百科ntil the page is loaded?


If you want to show progress indicator while the form is submitting why dont you use AJAX?

$("form").submit(function(e) {
    e.preventDefault();

$(".loading").show();//Assuming you have a container which has appropriate style and image to show the loading image

    $.post( {
       url: $(this).attr("action"), 
       data: $(this).serialize(),
       success: function(){ 
           $(".loading").show();
           //Write code here to handle on success 

        }
    });
});


This is trivial. Assuming you have a hidden spinner/loading image somewhere on your page with id 'loadingImg':

$("form").submit(function() {
    $("#loadingImg").show();
});

Demo: http://jsfiddle.net/yFaAj/1/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜