zoukankan      html  css  js  c++  java
  • 又一个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



  • 相关阅读:
    正则表达式的单行模式和多行模式
    js 正则匹配(去掉html标签)
    ES6中set和map的区别
    回调函数的使用场合
    javascript逻辑运算符“||”和“&&”
    [bzoj3210]花神的浇花集会
    [bzoj2438][中山市选2011]杀人游戏
    [bzoj2743][HEOI2012]采花
    [luoguP3729]曼哈顿计划EX
    [bzoj4850][Jsoi2016]灯塔
  • 原文地址:https://www.cnblogs.com/moyuling/p/5272503.html
Copyright © 2011-2022 走看看