Javascript loading huge data from ajax response
Using ajax how to get response from the server servlet as xm开发者_如何学Cl 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.???
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.
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.
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
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.
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.
Your UI will have a table with some sort of 'next' and 'previous' page buttons
精彩评论