码迷,mamicode.com
首页 > 数据库 > 详细

java定时器和实时查询数据库

时间:2018-07-16 19:33:49      阅读:691      评论:0      收藏:0      [点我收藏+]

标签:html   定时器   product   schedule   $.ajax   new t   hello   rod   ESS   

第一次写,还有缺陷,待改进

定时器:

  Timer timer = new Timer();
                    timer.schedule(new TimerTask() {
                        public void run() {
                          // 逻辑代码
                        }
                    }, 3600000);//一小时

 

实时查询:

  $(document).ready(function() {
         hello();
     });

  function hello(){
         $.ajax({
                url:"http://xxx.com/a/xx",
                type:"post",
                data:{sjl:1},
                dataType:"json",
                success:function(data){
                  var str = "";
                       for(var i = 0; i < data.length; i++){
                         str += "<div class=\"box-body\">";
                         str += "<ul class=\"products-list product-list-in-box\">";
                         str += "<li class=\"item\">";
                         str += "<div class=\"product-info\">";
                         str += "<a href=\"javascript:void(0)\" class=\"product-title\"></a>";
                         str += "<span class=\"product-description\">"+data[i]+"</span>";
                         str += "</div>" + "</li>" + "</ul>" + "</div>";
                       }
                  $("#cid").html(str);
                },
         })

  }

 

亲测可用!

java定时器和实时查询数据库

标签:html   定时器   product   schedule   $.ajax   new t   hello   rod   ESS   

原文地址:https://www.cnblogs.com/3b2414/p/9319306.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!