I want to create a web page using Graceful Degradation. That is, the function of the webpage is even javascript disabled. Now I have to make a design decision in AJAX response format.
If javascript is disabled, each HTTP request to the server will generate HTML as a response. The browser is updated with the returned HTML. It's fine.
If javascript is enabled, every AJAX HTTP request to the server will generate ... well, JSON or HTML.
If it's HTML, it's easy to implement. Just replace the part of the page with the returned HTML. And, on the server side, a lot of code changes are not required.
If it is JSON, I have to again implement the JSON-to-html logic in javascript, which almost duplicates the server-side logic. Duplication is evil . I really don't like it. The advantage is that bandwidth usage is better than HTML, which provides better performance.
So what is the best solution for elegant degradation? AJAX request is it better to return JSON or HTML?
source
share