显示进度条或加载图标,直到页面完全加载

showing progress bar or loading icon untill page fully loads?

本文关键字:加载 图标 显示      更新时间:2023-09-26

我正在将大型JSON数据填充到Jtable中。加载大约需要1分钟。我想要的是显示进度条,直到页面完全加载。我已经研究了一些Stackoverflow解决方案,但对我的问题不起作用。

 records = eval(objLangugaeTranslatorExt.listRecords(self._lastPostData));
                data['Records'] = records;
                data['TotalRecordCount'] = Object.keys(records).length;
                self._removeAllRows('reloading');
                self._addRecordsToTable(records);//Here I add the records to table taking too much time.

,请帮我

提前感谢。

不要使用eval()在用户数据上使用它是危险的。

您可以做一件事,在_addRecordsToTable()函数中,显示正在加载的DOM元素:

$(".loading").show();

并且在加载代码后,您可以放入:

$(".loading").hide();

对于HTML:

<div class="loading"></div>

就在<body>标记之后。在CSS中:

.loading {position: fixed; left: 0; top: 0; bottom: 0; right: 0; background: url("loading.gif") center center no-repeat rgba(0, 0, 0, 0.25);}