• table+ajax加载数据


    //ajax加载notice
        $(function() {
            //${pageContext.request.contextPath}/
            /**
            var res = [
                {noticeTitle:'必答题',noticeDate:'2019-08-09'},
                {noticeTitle:'必答题',noticeDate:'2019-08-09'},
                {noticeTitle:'必答题',noticeDate:'2019-08-09'},
                {noticeTitle:'必答题',noticeDate:'2019-08-09'},
                {noticeTitle:'必答题',noticeDate:'2019-08-09'}
            ];
            loadNotice(res);
            */
            url = "getDatas.do";
            $.ajax({
                url : url,
                type : "post",
                dateType : "text",
                success : function(res) {
                    loadNotice(res); //加载notice                    
                }
            });
            
        });
     
        //加载notice
        function loadNotice(res) {
            var tBody = $("#noticeTable").find("tbody");
            for ( var index in res) {
                //新建一行
                var newTr = $("<tr></tr>");
                //新建节点
                var newsTd = $("<td></td>");
                var dateTd = $("<td></td>");
                //新建超链接
                var newsA = $("<a></a>");
     
                //添加内容和时间
                var noticeTitle = res[index].noticeTitle;
                var noticeDate = res[index].noticeDate;
                /* alert(noticeTitle);
                alert(noticeDate); */
                newsA.text(noticeTitle);
                dateTd.text(noticeDate);
     
                //添加数据td-tr-tbody
                newsTd.append(newsA);
                newTr.append(newsTd);
                newTr.append(dateTd);
                tBody.append(newTr);
            }
        }
    <table id="noticeTable" class="table table-striped table-hover">
    				<tr>
    					<th class="col-md-3">活动标题</th>
    					<th class="col-md-1">发布时间</th>
    				</tr>
    			</table>
    
    为之一笑:
    客户被绑,蒙眼,惊问:“想干什么?” 对方不语,鞭笞之,客户求饶:“别打,要钱?” 又一鞭,“十万够不?” 又一鞭,“一百万?” 又一鞭。客户崩溃:“你们TMD到底要啥?” “要什么?我帮你做项目,写代码的时候也很想知道你TMD到底想要啥!”
  • 相关阅读:
    Java中的Java.lang.ThreadLocal类
    Java中线程的生命周期和状态
    Circular Linked List数据结构
    Linked List数据结构
    JVM如何工作
    JVM运行时数据区域
    queue数据结构
    stack数据结构
    Java中Set/HashSet的内部处理
    POJO,JavaBean 以及他们之间的区别
  • 原文地址:https://www.cnblogs.com/XuanZP/p/11713830.html
Copyright © 2020-2023  润新知