【发布时间】:2014-08-27 19:15:16
【问题描述】:
我在服务器端(在 db 中运行多个查询)有一个长时间运行的进程(不是确定的时间),需要 30 多秒。我想以 % 的形式向用户显示进度。我在我的应用程序中使用 jquery ,struts 。 有办法吗?
【问题讨论】:
标签: jquery ajax jquery-ui struts2 struts2-jquery
我在服务器端(在 db 中运行多个查询)有一个长时间运行的进程(不是确定的时间),需要 30 多秒。我想以 % 的形式向用户显示进度。我在我的应用程序中使用 jquery ,struts 。 有办法吗?
【问题讨论】:
标签: jquery ajax jquery-ui struts2 struts2-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);
}
});
}
希望这对你有用:)
【讨论】: