我使用一个<a>元素来下载HTML页面中的文件。这需要几秒钟,所以我想通过监听http响应来显示负载。
有没有一种方法可以在单击<a>元素时显示加载,并在下载完成后关闭加载?
这就是我要的:
<a href="https://..." download>download file</a>
Run Code Online (Sandbox Code Playgroud)
有两种方法:
$(document).ready(function(){
$("button").click(function(){
$.ajax({url: "/getData", success: function(result){
$("#div1").html(result);
}});
});
});
Run Code Online (Sandbox Code Playgroud)
在服务器发送事件:
socket.emit('sendData', 'Your Data');
Run Code Online (Sandbox Code Playgroud)
在客户端监听事件:
socket.on('sendData', function(data) {
console.log(data); // Your Data
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
100 次 |
| 最近记录: |