Fork me on GitHub
魔芋铃

又一个ajax实例,结合jQuery

又一个ajax实例,配合jQuery

 
html
  1. <!DOCTYPE html>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="renderer" content="webkit"><!--360,以webkit内核进行渲染-->
  6. <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"><!--以最新内核进行渲染。-->
  7. <meta http-equiv="Cache-Control" content="no-siteapp"/><!--百度禁止转码-->
  8. <title>moyu demo</title>
  9. <meta name="keywords" content="demo 测试 魔芋">
  10. <meta name="description" content="魔芋的测试示例">
  11. <meta name="robots" content="index,follow"><!--定义网页搜索引擎索引方式-->
  12. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  13. <script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
  14. <style>
  15. </style>
  16. </head>
  17. <body>
  18. <button>moyu</button>
  19. <p></p>
  20. <script>
  21. $("button").click(function(){
  22. $.post('http://localhost/moyu.php',{
  23. name:"nihao",
  24. city:"monkey"
  25. },function(data, status){
  26. $("p").html("Data: "+ data +"<br>"+"Status: "+ status);
  27. })
  28. });
  29. </script>
  30. </body>
  31. </html>
 
php
  1. <?php
  2. $name = isset($_POST['name'])? htmlspecialchars($_POST['name']):'';
  3. $city = isset($_POST['city'])? htmlspecialchars($_POST['city']):'';
  4. echo 'Dear '. $name;
  5. echo " ";
  6. echo 'Hope you live well in '. $city;
  7. ?>
 
魔芋:测试结果:
 
 
34.gif

 



 

posted @ 2016-03-13 17:16  魔芋铃  阅读(286)  评论(1编辑  收藏  举报