Use the post () method to send data from the server in post

Source: Internet
Author: User

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 Code
1 <? PHP 2 $num = $_post[' num ']; 3 if ($num%2==0) {4     echo "even"; 5 }else{6     echo "odd"; 7 }
View Code

Use the post () method to send data from the server in post

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.