Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 4
    what if you need to do some calculations and also incorporate it to the page's DOM? Commented Feb 1, 2012 at 2:56
  • I wonder how long will the above statement have a truthfulness attached to it, If you add the "Half-life of Knowledge" into equation? Commented Jul 2, 2014 at 9:44
  • is it possible to return an HTML that has <script> tags and then executes them on the client side when the page is loaded ? Commented Apr 13, 2016 at 10:00
  • This. Also if you are returning data that needs to be fluid in its presentation in some way, e.g. if you have an HTML table with columns that you would like to be able to sort. Whether you HAVE made them sortable now or not, you might want to later, so in such a case, the future-proofing is worth the extra effort of going the JSON route. Commented Jul 25, 2016 at 18:47
  • I would also add, if you are requesting image urls via JSON just to try to render them on the page, it's far more performant to include them in HTML from the start, so that images can start loading earlier (before your ajax comes back). Commented May 15, 2019 at 12:18