如何在 HTML 中单击按钮后将进度条(使用 Ladda)与按钮绑定
How to bind progress bar (use Ladda) with a button after button clicks in HTML?
我有一个进度条和一个按钮点击。现在进度条未与按钮链接。那么我该如何确保:当按钮单击时,进度条启动;当从服务器检索结果时,进度条停止?一些身体可以帮忙吗?
我想尝试使用一些隐藏字段作为标志来通知进度条,但还没有时间尝试。
HTML 按钮在这里:
<section class="progress-demo">
<button id="sendRequest_1" onclick="SendRequest(1)" type="button" class="btn btn-danger ladda-button" data-style="expand-left"><span class="ladda-label">Send</span></button></section>
进度条正在使用
<script src="js/spin.min.js"></script><script src="js/ladda.min.js"></script>
进度条在这里:
<script>
// Bind normal buttons
Ladda.bind( 'section:not(.progress-demo) button', { timeout: 2500 } );
//Ladda.bind( 'input[type=submit]' );
// Bind progress buttons and simulate loading progress
Ladda.bind( 'section.progress-demo button', {
callback: function( instance ) {
var progress = 0;
var interval = setInterval( function() {
progress = Math.min( progress + Math.random() * 0.1, 1 );
instance.setProgress( progress );
if( progress === 1 ) {
instance.stop();
clearInterval( interval );
}
}, 200 );
}
} );
按钮点击功能在这里。
function SendRequest(i){
alert("button clicked!");
//call post to get server response
... say 1s to get response
//how to bind it to progress bar when server response is back??
}
...
var l = Ladda.bind( 'section:not(.progress-demo) button', { timeout: 2500 } );
...
function SendRequest(i){
$.ajax({
url: "some.php",
success: function(data){
l.stop();
}
});
}
相关文章:
- 按下一个HTML按钮,该按钮使用一个功能在同一个新窗口中打开URL
- 捕捉Twitter的点击“;Tweet”;按钮使用jQuery
- 使用JavaScript对多个按钮使用onclick
- 为什么我应该为单个按钮使用数据dojo类型
- 使用单选按钮使用Jquery显示内容
- chrome扩展按钮使用browser_action基本q突出显示
- 阻止HTML单选按钮使用javascript或jquery在箭头键上进行选择
- 在提交和处理PHP代码后禁用提交按钮(使用AJAX提交?
- Jquery切换按钮使用.s兄弟取消选择
- 为什么'我的HTML5视频控制按钮使用Javascript
- 使用 Zurb Foundation 5 启用下拉按钮 - 使用 sass mixins
- PrimeFaces 命令按钮使用 jQuery 更新数据表内部
- JavaScript 按钮使用 curl 单击
- 点击提交按钮使用javascript和Firefox
- 根据按钮的值对按钮使用不同的方法
- 查询单选按钮 使用 JavaScript 和 IE8 单击的事件
- 在计算器中创建一个 CE 按钮,该按钮使用 jQuery 删除文本框中的文本
- 当触发器按钮使用 jquery 和 ajax 时,无法更新会话
- 在量角器中对多个按钮使用循环
- 使用不同的按钮使用javascript计算表单