zoukankan      html  css  js  c++  java
  • ___Html页面使用Ajax做数据显示

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link href="Content/js/css/bootstrap.css" rel="stylesheet" />
    <script src="Content/js/jquery-3.1.1.js"></script>
    <style>

    th {
    background-color: #0094ff;
    color: #f2f4f6;
    text-align: center;
    }

    td {
    text-align: center;
    }
    </style>
    <script>
    //文档就绪
    $(function () {
    //跳转页面
    $("#btnAdd").click(function () {
    location.assign("AddContacts.html");
    })
    Search();//查询功能
    })
    function Search() {
    $("#list #newtr").remove();
    var Name = $("#Name").val();
    $.ajax({
    url: "Handlers/ShowHandlers.ashx",
    type: "post",
    data: { "Name": Name },
    dataType: "json",
    success: function (data) {
    console.log(data);
    if (data.length > 0) {
    var t = $("#list");
    $(data).each(function () {
    t.append("<tr id='newtr'>"
    + "<td>" + this.Name + "</td>"
    + "<td>" + (this.Sex ? "男" : "女") + "</td>"
    + "<td>" + this.Provences + ',' + this.City + "</td>"
    + "<td>" + this.Email + "</td>"
    + "<td>" + this.Tel + "</td>"
    + "<td><a href='Upd.html?Id=" + this.Id + "'>修改</a></td>"
    + "</tr>")
    })
    }
    }
    })
    }
    </script>
    </head>
    <body>
    <div style="700px;margin:auto">
    <h3><b>数据管理</b></h3>
    <hr />
    <p>
    <input id="btnAdd" type="button" value="添加通讯录" class="btn btn-default" /><input id="Name" type="text" /><select id="selSex">
    <option value="0">男</option>
    <option value="1">女</option>
    </select><input id="btnSearch" type="button" value="查询" class="btn btn-default" onclick="Search()" />
    </p>
    <table class="table table-bordered" id="list">
    <tr>
    <th>姓名</th>
    <th>性别</th>
    <th>地址</th>
    <th>邮箱</th>
    <th>手机号</th>
    <th>操作</th>
    </tr>
    </table>

    </div>
    </body>
    </html>

  • 相关阅读:
    营销型站点的建设流程是什么?
    MAC 通过brew安装软件
    Android实现分享内容到微信朋友圈
    C++设计模式之适配器模式(三)
    JEECG平台权限设计
    .Net修改网站项目调试时的虚拟目录(未验证)
    .Net修改网站项目调试时的虚拟目录
    ECharts.js学习动态数据绑定
    百度ECharts
    asp.net loading 动画
  • 原文地址:https://www.cnblogs.com/100234ltf/p/9872590.html
Copyright © 2011-2022 走看看