Do you Ajax JSON or HTML?

Viewed 7130

What is the preferred way to do AJAX.

If it was for a search page written in PHP using Jquery for the AJAX

How would you handle the response

a) Have the response contain all the relevant html/styling

or

b) Send pure JSON and have a javascript function build the html/styling around the javascript variables.

I can see advantages to both. 'a' is obviously easier whilst 'b' is more efficient (although gzip would probably make the difference negligible).

6 Answers
Related