jQuery.post(url, [data], [callback], [type])
Overview
Load information via remote HTTP POST request.
This is a simple POST request function to replace the complex $.ajax. The callback function can be called when the request is successful. If you need to execute a function on error, use $.ajax.
Parameters
url,[data],[callback],[type]String,Map,Function,StringV1.0
url: Send request address.
data: Key/value parameters to be sent.
callback: callback function when sending successfully.
type: Return content format, xml, html, script, json, text, _default.
Example
1) Pass an array of data to the server (while still ignoring the return value):
jQuery code:
1 |
|
2) Send form data using ajax request:
jQuery code:
1 |
|
3) Test the page .php sends data and outputs the result (HTML or XML, depending on the returned content):
jQuery code:
1 2 3 4 |
|
4) Get the content of the test.php page and store it as an XMLHttpResponse object and pass it through process() This JavaScript function is processed:
jQuery code:
1 2 3 4 |
|
5) Get the json format content returned by the test.php page:
jQuery code:
1 2 3 4 5 |
|