Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP AJAX pagination

Tags:

jquery

ajax

php

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?

like image 753
j3ffz Avatar asked Feb 13 '26 16:02

j3ffz


2 Answers

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

like image 140
SomeDudeSomewhere Avatar answered Feb 15 '26 04:02

SomeDudeSomewhere


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.

like image 31
Stijn Leenknegt Avatar answered Feb 15 '26 06:02

Stijn Leenknegt