Using ajax how to get response from the server servlet as xml that contains more than 50000 records. If i try show that records in user interface it is very slow and freezed how to avoid it.???
使用ajax如何从服务器servlet获取包含超过50000条记录的xml的响应。如果我尝试在用户界面中显示记录它是非常慢和冻结如何避免它。
2 个解决方案
#1
0
jsonp is much faster that ajax. The reason is that most browsers parse javascript
tags really fast. See here, http://devlog.info/2010/03/10/cross-domain-ajax/ to get started (Solution 2 which deals with implementing jsonp.
jsonp比ajax快得多。原因是大多数浏览器都非常快速地解析javascript标签。请参阅http://devlog.info/2010/03/10/cross-domain-ajax/以开始使用(解决方案2,它涉及实现jsonp。
The downside to this is that you need to modify your server.
这样做的缺点是您需要修改您的服务器。
You could also load less records, or use paging.
您还可以加载较少的记录,或使用分页。
EDIT -- to use paging you are going to need to create a server endpoint that supports some sort of api fields like start
and size
. So you would do
编辑 - 要使用分页,您需要创建一个支持某种api字段(如start和size)的服务器端点。所以你会这样做
http://www.example.com/data?start=0&size=100
this means that the server should return 100 elements of data starting at the first. if you changed start from 0 to 1000, it would return 100 elements starting at the 1000th element.
这意味着服务器应该从第一个开始返回100个数据元素。如果你从0开始改为1000,它将返回从第1000个元素开始的100个元素。
Its just a simple ajax call. The only thing you do differently is tell the server how much data you want, starting where, by adding those parameters to your request.
它只是一个简单的ajax调用。您做的唯一不同的事情是通过将这些参数添加到您的请求,告诉服务器您想要多少数据,从哪里开始。
Your UI will have a table with some sort of 'next' and 'previous' page buttons
您的UI将有一个包含某种“下一页”和“上一页”页面按钮的表格
#2
1
As already suggested in other responses,you'll need to page your data. This probably means that the server side will have to be adapted to support paging as well.
正如其他回复中所建议的那样,您需要分页数据。这可能意味着服务器端也必须适应支持分页。
This example from the very excellent Datatables JQuery plugin also shows the server code that implements paging. Although that code is in PHP it might be a good idea to study that code to understand the concept of paging.
来自非常出色的Datatables JQuery插件的这个例子也显示了实现分页的服务器代码。尽管该代码在PHP中,但研究该代码以理解分页的概念可能是个好主意。
#1
0
jsonp is much faster that ajax. The reason is that most browsers parse javascript
tags really fast. See here, http://devlog.info/2010/03/10/cross-domain-ajax/ to get started (Solution 2 which deals with implementing jsonp.
jsonp比ajax快得多。原因是大多数浏览器都非常快速地解析javascript标签。请参阅http://devlog.info/2010/03/10/cross-domain-ajax/以开始使用(解决方案2,它涉及实现jsonp。
The downside to this is that you need to modify your server.
这样做的缺点是您需要修改您的服务器。
You could also load less records, or use paging.
您还可以加载较少的记录,或使用分页。
EDIT -- to use paging you are going to need to create a server endpoint that supports some sort of api fields like start
and size
. So you would do
编辑 - 要使用分页,您需要创建一个支持某种api字段(如start和size)的服务器端点。所以你会这样做
http://www.example.com/data?start=0&size=100
this means that the server should return 100 elements of data starting at the first. if you changed start from 0 to 1000, it would return 100 elements starting at the 1000th element.
这意味着服务器应该从第一个开始返回100个数据元素。如果你从0开始改为1000,它将返回从第1000个元素开始的100个元素。
Its just a simple ajax call. The only thing you do differently is tell the server how much data you want, starting where, by adding those parameters to your request.
它只是一个简单的ajax调用。您做的唯一不同的事情是通过将这些参数添加到您的请求,告诉服务器您想要多少数据,从哪里开始。
Your UI will have a table with some sort of 'next' and 'previous' page buttons
您的UI将有一个包含某种“下一页”和“上一页”页面按钮的表格
#2
1
As already suggested in other responses,you'll need to page your data. This probably means that the server side will have to be adapted to support paging as well.
正如其他回复中所建议的那样,您需要分页数据。这可能意味着服务器端也必须适应支持分页。
This example from the very excellent Datatables JQuery plugin also shows the server code that implements paging. Although that code is in PHP it might be a good idea to study that code to understand the concept of paging.
来自非常出色的Datatables JQuery插件的这个例子也显示了实现分页的服务器代码。尽管该代码在PHP中,但研究该代码以理解分页的概念可能是个好主意。