Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question on Best Practice

Status
Not open for further replies.

prgmrgirl

Programmer
Feb 12, 2004
119
US
Hey guys,

I'd like to know what your opinions are about the best way to send data.

If you have an webpage that uses Ajax:

Is it generally preferable to get small amounts of data when needed or to send all the data in one shot and manipulate it via client-side code?

Example: a page that uses ajax to get a product list from the server. The product list is an xml document, not very large (maybe about 100 nodes or so). The page is set up where a user clicks on a category and then the products that fall under that category are displayed. Would it be better to get the entire XML doc when the page loads and then manipulate it client-side? Or should the xml be queried server-side and send back only the products that fit that category?

Thanks for your help!
 
Best idea is for one shot, the server resources are used up a LOT more with multiple small requests to the server.

<.

 
I don't think it has a general answer. Maybe at server side you can cache the most used products.

Cheers,
Dian
 
The page is set up where a user clicks on a category and then the products that fall under that category are displayed.

I'm sorry, I didn't catch that part originally.

In this case, you want only the small amounts, your page will load up faster.

I was assuming you were going to use ALL the data on the page, if it's based upon clicking on a category from a user, ALL the data won't nessarily be needed.

I actually came across this about a year ago, the original code was pulling all the data. We switched to AJAX and only pulled data based off a dropdown box. The page was WAY faster and the hits on the server were so fast it didn't make a difference.

But in the case where ALL the data gets used on the page every time, I would still say pull it all in one lump sum.


<.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top