Ruby on Rails Question:

Download Job Interview Questions and Answers PDF

Why do we use request.xhr? in rails?

Ruby on Rails Interview Question
Ruby on Rails Interview Question

Answer:

Conventional web application transmit information to and
from the sever using synchronous requests. This means you
fill out a form, hit submit, and get directed to a new page
with new information from the server.
When you interact with an Ajax-powered web page, it loads an
Ajax engine in the background. In response to an event web
application passes asynchronous request (XMLHttpRequest or
xhr). In fact it is javaScript object/method that performs
asynchronous interaction with the server, JavaScript object
that performs asynchronous interaction with the server and
behind the scene fetches data. and behind the scene fetches
data.
We do request.xhr? only to check the request type, either
its AJAX request or others(post, get).

Download Ruby on Rails Interview Questions And Answers PDF

Previous QuestionNext Question
What is difference between form_for and form_tag?what the difference between static scaffolding and Dynamic scaffolding?