Reputation: 715
I've built a PHP AJAX pagination that works with an HTML Table. I have a quick question about the AJAX GET Response. Currently.. my pagination script returns the entire HTML table with each GET Response, then empties the DIV where the html table is contained and then places the new HTML table inside the DIV. My question is... Is it better to return the data in JSON or XML format and then build the table within the JavaScript?
Upvotes: 3
Views: 1076
Reputation: 28187
While I know this doesnt directly answer your question, I'd really consider checking out the PEAR Pager class - http://pear.php.net/package/Pager.
It's a great little class that I have used in a few web applications I've built and has a bunch of different options you can specify.
Upvotes: 0
Reputation: 6654
By doing this, you're going to save some network resources because of the smaller responses which is really good. On the other hand, you'll have more client processing because of the javascript needed to build the table. Make your choice :)
Upvotes: 2
Reputation: 3940
I would definitely build the table within javascript, this is scalable, and just a good practice for your whole website. Think about mobile clients for example, where every byte is precious.
Fetch json, which is so much lighter than the whole html build-out. Leverage your client's cpu :)
regards
Upvotes: 3
Reputation: 1347
In my opinion it's best to send data back to the client and then put the data in a table. How the data is send (JSON or XML) isn't important, but I prefer XML.
Upvotes: 2