Use the post () method to send data from the server in post
Compared with the get()
method, the post()
method is used to send data to the server in post, the server receives the data, processes it, and returns the processing result to the page, called the following format:
$.post(url,[data],[callback])
The parameter URL is the server request address, optionally the data to be sent to the server when requested, the optional callback parameter is the callback function executed after the request succeeds.
1<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">234<title> use the Post () method to send and get data from the server by post </title>5<script src= "Http://libs.baidu.com/jquery/1.9.0/jquery.js" type= "Text/javascript" ></script>6<style>7 #divtest8 {9 width:282px;Ten } One #divtest. Title A { - padding:8px; -background-Color:blue; the color: #fff; - height:23px; -line-height:23px; -font-size:15px; +font-Weight:bold; - } + ul A { at float: Left; - width:280px; - padding:5px 0px; - margin:0px; -font-size:14px; -list-style-Type:none; in } - ul Li to { + float: Left; - width:280px; the height:23px; *line-height:23px; $ padding:3px 8px;Panax Notoginseng } - . FL the { + float: Left; A } the . Fr + { - float: Right; $ } $</style> - - the<body> -<div id= "Divtest" >Wuyi<div class= "title" > the<span class= "FL" > Detection of Digital Parity </span> -<span class= "FR" ><input id= "btncheck" type= "button" value= "Detect"/></span> Wu</div> -<ul> About<li> Request input A number <input id= "Txtnumber" type= "text" size= "/></li>" $</ul> -</div> - -<script type= "Text/javascript" > A$(function () { +$ ("#btnCheck"). Bind ("click",function () { the$.post ("./8-5.php",{ -num:$ ("#txtNumber"). Val ()},function(data) { $$ ("ul"). Append ("<li> you enter <b>" the+ $ ("#txtNumber"). Val () + "</b> Yes <b>" the+ Data + "</b></li>"); the }); the }) - }); in</script> the</body> theView Code1 <? PHP 2 $num = $_post[' num ']; 3 if ($num%2==0) {4 echo "even"; 5 }else{6 echo "odd"; 7 }
View CodeUse the post () method to send data from the server in post