我有一个用于数据分析的应用程序,我在创建表时遇到了一些性能问题.数据是从文档中提取的,重要的是所有数据都显示在一个页面上(不幸的是,分页不是一个选项).
使用jQuery,我向服务器发出ajax请求以检索数据.完成请求后,我将数据传递给输出函数.输出函数使用for循环遍历数据数组,并将行连接到变量.循环完成后,包含该表的变量将附加到页面上的现有div,然后我继续将事件绑定到表以处理数据.
使用一小组数据(~1000-2000行),它的工作效果相对较好,但有些数据集包含超过10,000行,导致Firefox崩溃,关闭或无响应.
我的问题是,有没有更好的方法来完成我正在做的事情?
这是一些代码:
//This function gets called by the interface with an id to retrieve a document
function loadDocument(id){
$.ajax({
method: "get",
url: "ajax.php",
data: {action:'loadDocument',id: id},
dataType: 'json',
cache: true,
beforeSend: function(){
if($("#loading").dialog('isOpen') != true){
//Display the loading dialog
$("#loading").dialog({
modal: true
});
}//end if
},//end beforesend
success: function(result){
if(result.Error == undefined){
outputDocument(result, id);
}else{
<handle error code>
}//end if
if($('#loading').dialog('isOpen') == true){
//Close the loading dialog
$("#loading").dialog('close');
}//end if
}//end success
});//end ajax
};//end loadDocument();
//Output …Run Code Online (Sandbox Code Playgroud)