Link to home
Start Free TrialLog in
Avatar of Rohit Bajaj
Rohit BajajFlag for India

asked on

How to Transfer large json from server to browser part by part

HI,
In my web application i build a json out of a query. And sometimes its very huge.
I am displaying the data from json on the web page.
I make an ajax call and wait for the full response and then display it on the web page with scrollbar.
If the json size is small then this approach is fine but with large json the page just hangs waiting for the data to come up.
A single page can hold approx 10 elements from the json.
So i need some way to transfer the initial 10 elements of json quickly and then display it on page and the rest can come lazily which anyway the user will see only if he scrolls down.

I think there could be two approaches to it :
1) Send the initial 10 elements so that user can see it. And at the back keep waiting till the data is transfered and just append it to web page. and if the user scrolls meanwhile he just waits with a loading image showing

2) Other appraoch could be only when the user scrolls down do i make a call from say next 20 elements...and append it to the web page.

Please suggest which way is better and feasible.
Also how do i go about coding this in javascript and java.
how is such a problem solved.
Also any better approach ?

Thanks
Avatar of Kim Walker
Kim Walker
Flag of United States of America image

I have removed the Java EE tag as this question is not related to Java -- only to javascript.
ASKER CERTIFIED SOLUTION
Avatar of Kim Walker
Kim Walker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial