簡體   English   中英

在提交表單之后和運行腳本期間,如何啟動加載微調器,並在腳本完成后停止加載?

[英]How could I start a loading spinner after submitting a form and during running the script and stop loading after script finishes?

我有一個帶有提交輸入的表單

<input type="submit" class="download">

它負責運行下載某些文件的php&java腳本,我想在單擊按鈕時啟動按鈕上的加載微調器,並在腳本運行時繼續。

這是加載功能,它可以與特定的超時一起使用,我希望它或類似的功能在腳本運行期間一直運行到完成運行。

$('.download').on('click', function() {
var $this = $(this);
setTimeout(function(){$this.button('loading'); $this.button('reset');,8000););

簽出ladda.js以獲得漂亮的按鈕微調器示例

$('.download').on('click', function() {

    var $this = $(this);
    $this.button('loading');
    // Run your script here
    $this.button('reset');

);

或者,如果您的腳本具有異步回調,請執行以下操作:

$('.download').on('click', function() {

    var $this = $(this);
    $this.button('loading');

    runMyScript(function() {
        $this.button('reset');
    });
);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM