zoukankan      html  css  js  c++  java
  • jQuery Ajax: $.post请求示例

    jQuery Ajax: $.post请求示例

    leyangjun.html页面

    <html>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript" src="./jquery-2.0.0.min.js"></script>
    <script>
     $(document).ready(function(){
      $("#sub").click(function(){
       $.post("leyangjun.php",{name:$("#name").val()},function(data,textStatus){
        $("#result").append("data:"+data.name);
    $("#result").append("<br>age:"+data.age);
        $("#result").append("<br>textStatus:"+textStatus);
       },"json");
       return false;
      });
     });
    </script>
    </head>
    <body>
    <form action="testPost.php" method="post">
     <input type="text" name="name" id="name" >
     <input type="submit" id="sub" value="提交">
    </form>
    <h2>页面显示回来的内容</h2>
    <div id="result"></div>
    </body>

    </html>


    相应的页面leyangjun.php

    <?php 
    echo json_encode(
    array(
    "name" => $_POST['name'],
    "age" => 110,
    )
    );
    ?

    >

  • 相关阅读:
    全网数据库大全
    Docker最全教程
    枚举策略
    POJ 1012
    阿里云轻量应用服务器入门(二)
    阿里云轻量应用服务器入门(一)
    云服务器ECS
    Codeforces 768B B. Code For 1
    链剖&LCT总结
    O(1) 查询gcd
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/5038299.html
Copyright © 2011-2022 走看看