我有一个获取大型 json 列表的 ajax 调用。有什么方法可以制作一个进度条来获取 json 加载的实际值(例如,状态栏显示 200 次加载中有 1 次已加载)?
现在我有一个非常基本的 Ajax 调用
function SendAjax(urlMethod, jsonData, returnFunction) {
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
url: urlMethod,
data: jsonData,
dataType: "json",
success: function (msg) {
if (msg != null) {
ReturnJson(msg);
}
},
error: function (xhr, status, error) {
// Boil the ASP.NET AJAX error down to JSON.
var err = eval("(" + xhr.responseText + ")");
// Display the specific error raised by the server
alert(err.Message);
}
});
}
最佳答案
尝试使用 AjaxStart在您的应用程序全局范围内。这意味着你可以把代码放在你的布局文件中,如果处理时间很长,它会显示进度指示器......
$(document).ajaxStart(function() {
$( "#loading" ).show();
});
您可以在 preload with percentage - javascript/jquery 查看示例和答案.
关于javascript - 带有大列表的 Ajax 进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16661547/