1
我有一個長時間運行的進程(不確定時間)在服務器端(運行數據庫中的查詢數量),這需要超過30秒。我想向用戶顯示%的進度。我在我的應用程序中使用jquery,struts。 有沒有辦法做到這一點?Jquery進度條服務器端
我有一個長時間運行的進程(不確定時間)在服務器端(運行數據庫中的查詢數量),這需要超過30秒。我想向用戶顯示%的進度。我在我的應用程序中使用jquery,struts。 有沒有辦法做到這一點?Jquery進度條服務器端
這就是我們如何做到的。
以下是ajax調用的示例方法。
function updateProgress() {
if (stopProgressCheck) return;
var webMethod = progressServiceURL + "/GetProgress";
var parameters = "{'guid':'" + guid + "'}"; //passing the guid value
$.ajax({
type: "POST",
url: webMethod,
data: parameters,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d != "NONE") { //add any necessary checks
//add code to update progress bar status using value in msg.d
statusTimerID = setTimeout(updateProgress, 100); //set time interval as required
}
},
error: function (x, t, m) {
alert(m);
}
});
}
希望這是對你有用:)
http://tpeczek.blogspot.ie/2010/07/reporting-server-side-operation.html –
http://stackoverflow.com/問題/ 12756047 /更新模式換進度條上,一長的Ajax查詢 –