![]() |
VOOZH | about |
In this article, we will see the common methods of sending requests to a server by using the jQuery library. jQuery is an open-source JavaScript library jQuery simplifies HTML document traversing and manipulation, browser event handling, DOM animation, Ajax interactions cross-browser JavaScript development.
Common methods of Sending Requests to the Server: jQuery has two methods get() and post() that method used for sending get request and post requests to the server.
Using the jQuery get() method to send the request to the server: The $.get() method loads data from the server
Syntax:
$.get(url,callback);
Parameters:
Example 1: In this example, we will make a data.txt file. This file will be returned when you click the Get Request Button.
data.txt:
GeeksforGeeks
index.html:
Output
Using the jQuery post() method to send requests to Server: The post() method loads data from the server or sends the data to the server
Syntax:
$(selector).post(url,data,callback ,data Type);
Parameters:
Example 2: This example uses the post() method for sending the request to the server.
data.php: The file will be called when you click the Post Request Button.
index.html:
Output: