2013-12-20 26 views
0

我對「引導程序3的Ladda UI」有點困惑,它將加載指示符合併到調用它們的動作中。當我點擊按鈕時,它會執行一個SQL查詢。那麼,如何在查詢完成後停止旋轉效果?我使用jsp和servlets。如何使用Ladda UI進行引導3

回答

-1

參見:http://msurguy.github.io/ladda-bootstrap/的文件。

$(function() { 
    $('#form-submit').click(function(e){ 
     e.preventDefault(); 
     var l = Ladda.create(this); 
     l.start(); 
     $.post("your-url", 
      { data : data }, 
      function(response){ 
      console.log(response); 
      }, "json") 
     .always(function() { l.stop(); }); 
     return false; 
    }); 
}); 

這裏your-url應是瓶坯您的SQL一個網址,這個網址的結果應該是:

The type of data that you're expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). The available types (and the result passed as the first argument to your success callback) are: xml, html, json, jsonp or text 

現在,您可以根據您的響應數據或AJAX請求調用l.stop;

// Assign handlers immediately after making the request, 
// and remember the jqxhr object for this request 
var jqxhr = $.post("example.php", function() { 
    alert("success"); 
}) 
    .done(function() { 
    alert("second success"); 
    }) 
    .fail(function() { 
    alert("error"); 
    }) 
    .always(function() { 
    alert("finished"); 
});