It depends.
Obviously, you want to reduce bandwidth usage to a minimum, but there is also overhead for each individual call. You have to make some reasonable guesses, and most importantly: how likely is it that you will need data from pages 2 to 100?
If this is very likely (say, in 90% of cases, users will click on several pages of the same result set), then I would load the whole result at a time, but otherwise I would load separate pages in the process.
Another thing to keep in mind is latency. Each ajax call has a certain delay, depending on the distance (in the network topology, not necessarily geographical) between the client and server. Latency is inevitable for the first load, but after that you need to ask yourself if a quick response is important. Under normal circumstances, this is expected and acceptable, but if your typical use case involves repeatedly flipping between pages, this can be a nuisance, and you might consider buying an attachment for a longer initial loading time.
If you want to load several pages, but the result set is too large (say, thousands or millions of pages), you can think of more complex schemes, for example, load the requested page and the next 10 or load the requested page, and then pre-select the next 10 pages in background mode.
source share