An post of method usage instance of ajax in jQuery
- 2020-05-10 17:36:55
- OfStack
This article illustrates the use of the post() method for ajax in jQuery as an example. Share with you for your reference. The specific analysis is as follows:
The $.post () method requests data from the server via the HTTP POST request.
Grammatical structure:
$.post(URL,data,callback);
Parameter analysis:
1.URL: must, specify the requested URL.
2.data: optional, specifying the data to be sent along with the request.
3.callback: optional, specifying the name of the function to be executed after the request is successful.
Code example:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="//www.ofstack.com/" />
<title> The home of the script </title>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#bt").click(function(){
$.post("mytest/demo/antzone.html",function(data,status){
alert("Data:"+data+"\nStatus:"+status);
})
})
})
</script>
</head>
<body>
<input type="button" value=" See the effect " id="bt"/>
</body>
</html>
I hope this article is helpful for you to design jQuery program.