jQuery post() Method

## jQuery Tutorial

jQuery HOME jQuery Intro jQuery Install jQuery Syntax jQuery Selectors jQuery Events

## jQuery Effects

jQuery Hide/Show jQuery Fade jQuery Slide jQuery Animate jQuery stop() jQuery Callback jQuery Chaining

## jQuery HTML

jQuery Get jQuery Set jQuery Add jQuery Remove jQuery CSS Classes jQuery css() jQuery Dimensions

## jQuery Traversing

jQuery Traversing jQuery Ancestors jQuery Descendants jQuery Siblings jQuery Filtering

## jQuery AJAX

jQuery AJAX Intro jQuery Load jQuery Get/Post

## jQuery Misc

jQuery noConflict()

## jQuery Examples

jQuery Examples jQuery Quiz jQuery Certificate

## jQuery References

jQuery Selectors jQuery Events jQuery Effects jQuery HTML/CSS jQuery Traversing jQuery AJAX jQuery Misc jQuery Properties

# jQuery post() Method

jQuery AJAX Methods

## Example 1

Load data from the server using a HTTP POST request:

$("button").click(function(){
$.post("demo_test.asp",function(data,status){
alert("Data: " + data + "\nStatus: " + status);
});
});
Try it yourself »

## Example 2

Change the text of a <div> element using an AJAX POST request:

$("input").keyup(function(){
txt=$("input").val();
$.post("demo_ajax_gethint.asp",{suggest:txt},function(result){
$("span").html(result);
});
});
Try it yourself »

## Definition and Usage

The $.post() method loads data from the server using a HTTP POST request.

## Syntax

$(selector).post(URL,data,function(data,status,xhr),dataType)

Parameter | Description
--- | ---
URL | Required. Specifies the url to send the request to
data | Optional. Specifies data to send to the server along with the request

function(data,status,xhr)

Optional. Specifies a function to run if the request succeeds
Additional parameters:

- data - contains the resulting data from the request
- status - contains the status of the request ("success", "notmodified", "error", "timeout", or "parsererror")
- xhr - contains the XMLHttpRequest object

dataType

Optional. Specifies the data type expected of the server response.
By default jQuery performs an automatic guess.
Possible types:

- "xml" - An XML document
- "html" - HTML as plain text
- "text" - A plain text string
- "script" - Runs the response as JavaScript, and returns it as plain text
- "json" - Runs the response as JSON, and returns a JavaScript object
- "jsonp" - Loads in a JSON block using JSONP. Will add an "?callback=?" to the URL to specify the callback

jQuery AJAX Methods

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE