php - Load ajaxdata in HTML or JSON-format? -


What is a better practice? Load data in HTML format or JSON-format? When I load the HTML, I am able to put all the html in my php view-file. When I load JSON, I have to put it in html elements with javascript.

I know that a 'best practice-question' is not suitable for stack overflow. So a better answer to my question is a list of the advantages and disadvantages of both techniques.

If you plan to call data often in the same session, better network traffic and accountability If you call only JSON data, the HTML / JS overhead that happens in the cache will only cross the network with the other call data.

However it seems that you need to render a table with TRS / TDS. If you do not call it often, you are better than a simple HTML dump.

Another idea is to clearly separate the data and the view for cleaner code and easy maintenance. A JSON call allows explicit separation between data and HTML. Both are mixed in an HTML dump.

I just answered another question, it was for JSP, but it could interest you.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -