一个正常的ajax实时进度条加载是这样的,
$.ajax({
xhr: function() {
var xhr = new window.XMLHttpRequest();
xhr.upload.addEventListener("progress", function(e) {
var pro = (e.loaded / e.total) * 100;
$('.progress-bar-anim').css('width', pro + '%').attr('aria-valuenow', pro);
}, false);
return xhr;
},
type: "POST",
dataType: 'json',
url: "data.php",
data: {"username": username, "password": password},
success: function(msg) {
if (msg.status == 'success') {
window.location = "dashboard.php"
} else {
hide_progress();
}
}
});
我想在接收到服务器响应时在 jquery 数据表 中加载一个实时进度条。我应该怎么做?
最佳答案
在您的成功方法中创建表:
function getData() {
$.ajax({
url : 'example.com',
type: 'GET',
success : handleData
})
}
function handleData(data) {
table = $('#table').DataTable( {
"data": data,
....
}
关于javascript - jquery 数据表 : load real time progress bar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35069140/