2015-12-09 119 views
1

我正在向Jtable填充大型JSON數據。加載大約需要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. 

請幫助我,

在此先感謝。

回答

0

請勿使用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);} 
+0

謝謝你的幫助。問題是它的非常大的應用程序,我沒有寫這個函數_addRecordsToTable()。我怎麼能把這個$(「。loading」)。show(); –

+0

@ArunFebi無論你需要向我們展示完整的cod或者你需要編寫該功能... –

+0

這是函數:_addRecordsToTable:function(records){ alert(records); var self = this; $ .each(records,function(index,record){self__addRowToTable(self._createRowFromRecord(record)); }); self._refreshRowStyles(); } –

相關問題