POST Method
Learn about the post() AJAX method in jQuery along with an example.
post()
method
post()
is a jQuery AJAX method that loads data from a server with the help of an HTTP POST request.
The syntax for the post()
method is shown below:
jQuery.post(URL, Data, Callback, Datatype)
The description of each parameter is:
-
URL
- the specific server address to which the HTTP POST request is made, along with the requested resource/web page. Usually, this will be the URL of the server running your site. -
Data
- the information sent to the server via the request message body, usually in the form of key-value pairs. -
Callback
- the function executed after the successful completion of the POST request. The callback function receives two arguments,data
andtextStatus
.data
contains the response from the server in the specifiedDataType
.textStatus
contains the status of the POST request: success, etc. -
DataType
- the type of data expected from the server, such as JSON, text, HTML, XML, or others.
π Note: In the
post()
method,URL
is a required parameter, butCallback
,Data
andDataType
are optional parameters.
Get hands-on with 1200+ tech skills courses.