1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> 5 <title>jQuery $.get()</title> 6 <script type="text/javascript" src="js/jquery-1.11.3.js"></script> 7 <script type="text/javascript"> 8 $(document).ready(function(){ 9 $(‘button‘).click(function() { 10 $.get(‘demo_test.php‘,function(data,status){ 11 alert(‘数据:‘+ data + ‘\n状态:‘ + status); 12 }); 13 }); 14 }); 15 </script> 16 </head> 17 <body> 18 <button>向页面发送HTTP GET请求,然后获得返回的结果</button> 19 </body> 20 </html>
参数 |
描述
|
URL
|
希望请求的URL |
data
|
连同请求发送的数据 |
callback
|
请求成功后所执行的函数名 |
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> 5 <title>jQuery $.post()</title> 6 <script type="text/javascript" src="js/jquery-1.11.3.js"></script> 7 <script type="text/javascript"> 8 $(document).ready(function() { 9 $(‘button‘).click(function() { 10 $.post(‘demo_test_post.php‘,{name:"liubeimeng",city:"beijing"},function(data,status){ 11 alert(‘数据:‘+data+‘\n状态‘+status); 12 }); 13 }); 14 }); 15 </script> 16 </head> 17 <body> 18 <button>向页面发送 HTTP POST 请求 , 并获得返回的结果 .</button> 19 </body> 20 </html>
1 <?php 2 $name = $_POST["name"]; 3 $city = $_POST["city"]; 4 echo "我的名字是:",$name,"我的城市是:",$city; 5 ?>
原文:http://www.cnblogs.com/liubeimeng/p/5000736.html