Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How does jquery and ajax actually work?


Asked by Taylor Ware on Dec 06, 2021 AJAX



jQuery AJAX works asynchronously. The form does not get posted, as you can see it does not have an action or method attribute set on the form tag. jQuery intercepts the button click and sets up a new asynchronous request and then adds the data to that request and posts it to the server.
Moreover,
What About jQuery and AJAX? jQuery provides several methods for AJAX functionality. With the jQuery AJAX methods, you can request text, HTML, XML, or JSON from a remote server using both HTTP Get and HTTP Post - And you can load the external data directly into the selected HTML elements of your web page!
Next, That is, your javascript can send asynchronous GET and POST requests (usually via an XMLHttpRequest object) then use the results of those requests to modify its page (via Document Object Model manipulation). AJAX typically involves sending HTTP requests from client to server and processing the server's response, without reloading the entire page.
Keeping this in consideration,
By default, Ajax requests are sent using the GET HTTP method. If the POST method is required, the method can be specified by setting a value for the type option. This option affects how the contents of the data option are sent to the server.
In addition,
success A callback function to be executed when Ajax request succeeds. timeout A number value in milliseconds for the request timeout. type A type of http request e.g. POST, PUT and GET. Default is GET. url A string containing the URL to which the request is sent.