ruby on rails - javascript code or json objects as ajax response? -
I am reading railway guides, especially I am reading this: The part which is a bit confusing to me. It says that if Action Actions receives an AJAX request, it will return the JavaScript code which will include the user in the page. I have found other solutions in which the client gets the json object (instead of the JavaScript code) and creates the respective DOM elements and inserts them on the page. My questions are: What is the json object? Receive and create DOM elements and get them better than receiving the JavaScript code on the page and executing it so that the new content is added to the page? What are the best practices about this? In this example, what will get the AJAX call? Javascript code, a Jason object or both? There is no right or wrong way in the example that you have quoted, Ajax calls to Javascript will be received, which will then be executed in the browser. However, it is likely that you want to embed html in javascript feedback. For example, a rai...