我使用的是一个jQuery jTable,它首先给出消息“没有可用的数据”,然后加载数据并显示它的长列表。那么,在在后台加载数据时,是否可以首先显示Ajax加载器(loading.gif)呢?
编辑@Rex:我试过了,但不知道如何使用jQuery jTable success函数来实现它。
这是我尝试过的代码:
$(document).on('click', '#PlayStatisticone', function (e) {
function loadingAjax(div_id) {
var divIdHtml = $("#"+div_id).html();
$.ajax({
url: '@Url.Action("_TopPlayedTracksPermissionCheck", "ReportStatistic")',
type: 'POST',
beforeSend: function() {
$("#loading-image").show();
},
success: function (data) {
$("#"+div_id).html(divIdHtml + msg);
$("#loading-image").hide();
$(function () {
$("#PartialViewTopPlayedTracks").load('@Url.Action("_PartialViewTopPlayedTracks", "ReportStatistic")');
});
},
error: function (xhr, textStatus, exceptionThrown) {
var json = $.parseJSON(xhr.responseText);
if (json.Authenticated) {
window.location.href = '/UnAuthorizedUser/UnAuthorizedUser';
}
else {
window.location.href = '/UnAuthenticatedUser/UnAuthenticatedUser';
}
}
});任何建议都会很有帮助,谢谢。
发布于 2014-03-28 13:52:46
就像我想要的那样。我在另一个论坛上找到的
我不知道是否可以在这里发布其他论坛的有效答案:
下面是起作用的代码:
$(document).ready(function () {
// DOM is ready now
$.post("<%= Url.Action("ActionThatGetsTableOnly") %>",
"",
function(data) { $("#elementToReplaceId").html(); },
"html"
);
});https://stackoverflow.com/questions/22711793
复制相似问题