/ / jqueryデータ型:リアルタイムプログレスバーをロードする - javascript、jquery、ajax、datatables、jqxhr

jqueryデータ型:リアルタイムプログレスバーをロードする - javascript、jquery、ajax、datatables、jqxhr

通常の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データテーブル サーバーの応答が受信されています。私はそれについてどうすればよいですか?

回答:

回答№1は1

成功メソッドでテーブルを作成します。

function getData() {
$.ajax({
url : "example.com",
type: "GET",
success : handleData
})
}

function handleData(data) {
table = $("#table").DataTable( {
"data": data,
....
}