zoukankan      html  css  js  c++  java
  • php jquery ajax

    1.php文件如下
    <?php
    header('Content-Type:text/html;charset=utf-8');
    ?>
      
    <script type="text/javascript"src="http://code.jquery.com/jquery.min.js"></script>
    <scripttype="text/javascript">
    $(function() {
        $("#subbtn").click(function() {
            var params = $('input').serialize();
            var url = "你的服务器端 php";
      
            $.ajax({
                type: "post",
                url: url,
                dataType: "json",
                data: params,
                success: function(msg){
                    var tishi = "您提交的姓名为:" + msg.name +
                    "<br/> 您提交的密码为:" + msg.password;
                    $("#tishi").html(tishi);
                    $("#tishi").css({color: "green"});
                }
            });
        });
      
    });
      
    </script>
    <p><labelfor="name">姓名:</label>
    <inputid="name"name="name"type="text"/>
    </p>
      
    <p><labelfor="password">密码:</label>
    <inputid="password"name="password"type="password"/>
    </p>
      
    <spanid="tishi"></span>
    <p><inputid="subbtn"type="button"value="ajax 测试"/></p>
     
     
    2.服务器 PHP 代码如下

    <?php
    echo json_encode($_POST);
     

  • 相关阅读:
    Centos7 定时任务
    Linux启动配置文件和运行等级runlevel
    Linux 网卡命名规则
    将博客搬至CSDN
    Lua调用C++动态链接库.so
    使用shell脚本执行批量mongosh语句
    TCP和UDP详解
    经受时延的确认(Delay ACK)
    18张图带你了解衡量网络性能的四大指标:带宽、时延、抖动、丢包
    TCP学习
  • 原文地址:https://www.cnblogs.com/qhorse/p/4607309.html
Copyright © 2011-2022 走看看