use*_*764 2 ajax jquery struts2 jquery-ui struts2-jquery
我在服务器端(在db中运行查询数量)的过程运行时间长(不确定时间),耗时超过30秒。我想向用户显示进度百分比。我在应用程序中使用jquery,struts。有办法吗?
这就是我们做到的方式。
下面是进行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);
}
});
}
Run Code Online (Sandbox Code Playgroud)
希望这对您有用:)