can anyone tell me. What exactly is Ajax request? Is it different from Servlet Request?
XHR is the XMLHttpRequest Object which interacts with the server. Ajax technique in the nutshell leverages the XHR request to send and receive data from the webserver. This object is provided by the browser's javascript environment. It transfers the data between the web browser and server.
Steps of AJAX OperationAn XMLHttpRequest object is created. The XMLHttpRequest object is configured. The XMLHttpRequest object makes an asynchronous request to the Webserver. The Webserver returns the result containing XML document.
The ajax() methods performs asynchronous http request and gets the data from the server. The following example shows how to send a simple Ajax request.
You can in the servlet distinguish between normal requests and Ajax requests as below: @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String foo = request. getParameter("foo"); String bar = request.
An Ajax call is an asynchronous request initiated by the browser that does not directly result in a page transition. A servlet request is a Java-specifc term (servlets are a Java specification) for servicing an HTTP request that could get a simple GET or POST (etc) or an Ajax request.
An Ajax ("Asynchronous Javascript and XML") request is sometimes called an XHR request ("XmlHttpRequest"), which is the name most browsers give the object used to send an Ajax request, because at least initially Ajax calls involved the sending and receiving of XML but now it's just as common to send/receive JSON, plain text or HTML.
A good example of an Ajax request is the comment system on Stackoverflow. You can enter a comment in the textbox and click submit. It doesn't submit the whole page (like a traditional HTML form submission would, which translates into usually a POST but sometimes a GET HTTP request). Instead the browser will send probably a POST request via XHR to the server and be notified of the response (hence "asynchronous"). But the server typically can't distinguish between an Ajax request or a page transition because both simply come down to HTTP requests.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With