Jquery.post (URL, [data], [Success (data, Textstatus, XMLHttpRequest)], [datatype])
Returns:xmlhttprequest
Jquery.post (URL, [data], [Success (data, Textstatus, XMLHttpRequest)], [datatype])
The Ulla string that contains the URL of the request is sent.
Dataa a map or string of requests sent to the server.
Success (data, Textstatus, XMLHttpRequest) A callback function this is executed if the request succeeds.
Datatypethe type of data expected from the server.
This is a shorthand Ajax function and which is equivalent to:
$.ajax ({
Type: ' Post ',
Url:url,
Data:data,
Success:success
Datatype:datatype
});
This success is the data returned by the callback function, which will be an XML root element or a text string based on the MIME type of the response. It also passed the status of the response text.
In jquery 1.4, the successful callback function is also passed through the XMLHttpRequest object.
Most implementations will specify a successful handler:
$.post (' ajax/test.html ', function (data) {
$ ('. Result '). HTML (data);
});
Examples:
For example: Please test.php the tutorial page, but ignore the return result.
$.post ("test.php");
Example
Request the test.php page and send some additional data along (while still ignoring the return results).
Request a test.php Web page, sending some extra data along (while still ignoring the return result).
$.post ("test.php", {name: "John", Time: "2pm"});
Example:pass arrays of data to the server (while still ignoring the return results).
$.post ("test.php", {' choices[] ': ["Jon", "Susan"]});
Example:send form data using AJAX requests
$.post ("test.php", $ ("#testform"). Serialize ());
Example:alert out of the results from requesting test.php (HTML or XML, depending on what is returned).
$.post ("test.php", function (data) {
Alert ("Data loaded:" + data);
})
; Example:alert out the results from requesting test.php with a additional payload of data (HTML or XML, depending on WHA T was returned).
$.post ("test.php", {name: "John", Time: "2pm"},
function (data) {
Alert ("Data loaded:" + data);
Example:gets the test.php page content, store it in a Xmlhttpresponse object and applies the process () Web effects function.
$.post ("test.php", {name: "John", Time: "2pm"},
function (data) {
Process (data);
}, "xml");
Example:gets the test.php page contents which has been in JSON format ()
$.post ("test.php", {"Func": "Getnameandtime"},
function (data) {
alert (data.name); John
Console.log (Data.time); 2pm
}, "JSON");