Q:

Is it better to do raw data to HTML processing serverside or clientside?

I currently have a setup that works like this:
Serverside:

Retrieve data from MySQL 
Run the data through a loop that generates HTML. For example:

<div>
    Item 1:<br>
        Color: Red, Amount: 8, Cost: $15 each
    Item 2:<br>
        [...]
    [...]
</div>

Clientside:
Update a div's HTML with the received data: $("#details").html(result);
Would it be better to do something like this:
Serverside:

Retrieve data from MySQL
Run the data through a loop that generates a JSON object. For example:

{"result":
    "0":[{"Color":"Red"},{"Amount":"8"},{"Cost":"15"}], 
    "1":[...]
    [...]
}   

Clientside:
Parse into HTML and update the div with the parsed HTML. All the data delivered will be used somehow, and the end result will be exactly the same as if it were parsed serverside. The JSON object will be discarded once the function is done running.

A:

As mentioned in the comments section there's not a correct answer to this.  You aren't any more secure doing it one way or the other.  Serving up the HTML via an AJAX call will let your page load slightly faster since the majority of this processing is done server side rather than client side, though ultimately I would imagine you wouldn't see much of a difference either way, but you could certainly try it and find out.

