ajax post() method
Translation results:
post
UK[pəʊst] US[poʊst]
n.Post; post; mail; column, pile, pole
vt .Post; mail; announce; set up posts
vi.Move quickly
adj.Related to the starting point mark of a race (or horse racing, dog racing)
adv.〈Outside〉 behind; with urgent dispatch [Yima]; quickly, quickly
ajax post() methodsyntax
Function: post() method loads data from the server through HTTP POST request.
Syntax: jQuery.post(url,data,success(data, textStatus, jqXHR),dataType)
Parameters:
Parameters | Description |
url | Required. Specifies the URL to which the request should be sent. |
data | Optional. Map or string value. Specifies the data to be sent to the server with the request. |
success(data, textStatus, jqXHR) | Optional. The callback function executed when the request is successful. |
dataType | Optional. Specifies the data type of the expected server response. Intelligent judgment is performed by default (xml, json, script or html). |
Explanation: This function is the abbreviated Ajax function, equivalent to: $.ajax({ type: 'POST',url: url, data: data,success: success,dataType: dataType}); According to the different MIME types of the response, the return data passed to the success callback function is also different. These data can be XML root elements, text strings, JavaScript files or JSON object. You can also pass the textual status of the response to the success callback function. With jQuery 1.5, you can also pass a jqXHR object to the success callback function (in jQuery 1.4, an XMLHttpRequest object is passed). Most implementations will specify a success function: $.post("ajax/test.html", function(data) {$(".result").html(data);}); In this example, the requested HTML is read snippet and insert it into the page. Pages read via POST are not cached, so the cache and ifModified options in jQuery.ajaxSetup() will not affect these requests.
ajax post() methodexample
<!DOCTYPE html> <html> <head> <script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"> </script> <script> $(document).ready(function(){ $("button").click(function(){ $.post("", { name:"Donald Duck", team:"Duckburg" }, function(){ alert("数据:" + "Donald Duck" + "\n状态:" + "Duckburg"); }); }); }); </script> </head> <body> <button>向页面发送 HTTP POST 请求,并获得返回的结果</button> </body> </html>
Click the "Run instance" button to view the online instance
Popular Recommendations
- Understanding POST requests in Javascript
- Hello DevPeople . this is my first post .
- Dogecoin Sees Minimal Reaction Following Elon Musk's Post
- Roaring Kitty's X Post Sends CHEWY Token Soaring
- Crypto Market Turbulent Post-FOMC & BoJ Interest Rate Decisions
- Bitcoin (BTC) Miners Face Challenges and Adaptations Post-Halving