Ruby on Rails Developer Question:
Tell me how does Rails implement AJAX?
Answer:
Asynchronous JavaScript and XML (AJAX) is a suite of technologies used to retrieve data for a webpage without having to refresh the page itself. This is how modern websites are able to cultivate a “desktop-like” user experience. The Rails method of implementing AJAX operations is short and simple.
☛ First, a trigger is fired. The trigger can be something as simple as a user clicking on a call to action.
☛ Next, the web client uses JavaScript to send data via an XMLHttpRequest from the trigger to an action handler on the server.
☛ On the server-side, a Rails controller action receives the data and returns the corresponding HTML fragment to the client.
☛ The client receives the fragment and updates the view accordingly.
☛ First, a trigger is fired. The trigger can be something as simple as a user clicking on a call to action.
☛ Next, the web client uses JavaScript to send data via an XMLHttpRequest from the trigger to an action handler on the server.
☛ On the server-side, a Rails controller action receives the data and returns the corresponding HTML fragment to the client.
☛ The client receives the fragment and updates the view accordingly.
Previous Question | Next Question |
Explain what’s different between ActiveRecord::Relation’s count, length and size methods? | Do you know the role of garbage collection in Ruby on Rails? |