lundi 2 janvier 2017

In MVC, is it a good idea to let client JavaScript to handle the view component?

In a MVC web application, either PHP or ASP.net etc., is it a good idea to spit data to json/csv in a hidden div and let client side js to handle the presentation?

For example, if you want to present a table, instead of convert query results to HTML table at the server side (PHP or C# etc.), you can simply convert the query results to a json string and put it inside a div with display:none. And then, you use client side JavaScript to read the json data and present it as a HTML table or anything you want.

The benefit is that you can totally forget thinking about the presentation of the data while you are programming for the back end. You don't need to constantly revise the view code when you change the model / controller code, or vice visa.

One disadvantage is that there might be a risk for SEO.

Is there any other advantages or disadvantages?

Aucun commentaire:

Enregistrer un commentaire