zoukankan      html  css  js  c++  java
  • js每5分钟调用一次ajax

    <script>
    window.onload=function(){
    //假设这里每个五分钟执行一次test函数
    publicBusi();
    personBusi();
    }

    function publicBusi(){
    setTimeout(personBusi,1000*60*7);//这里的1000表示1秒有1000毫秒,1分钟有60秒,7表示总共7分钟
    doAjaxMgr({async: true, model: "randomReviewManager", method: "op_getReviewPerson", xzqh: xzqh}, function (obj) {
    var data = obj.data;
    var html = "";
    for (let i = 0; i < data.length; i++) {
    html += " <li><a href="sjcq_shi.jsp?xzqh="+data[i].xzqh+""><p>" + xzQhCity(data[i].xzqh) + "</p><span>" + data[i].count + "/" + data[data.length - 1].total + "</span></a></li> ";
    }
    $(".clearfix").append(html);
    $(".load").show();
    }, false);
    }

    function personBusi(){
    setTimeout(publicBusi,1000*60*5);//这里的1000表示1秒有1000毫秒,1分钟有60秒,5表示总共5分钟
    var title;
    doAjaxMgr({async: false, model: "randomReviewManager", method: "op_getXzqh", xzqh: value}, function (obj) {
    var data = obj.data;
    for (let i = 0; i < data.length; i++) {
    if (value == data[i].xzqh) {
    title = data[i].qhmc;
    }
    }
    }, true);
    return title;
    }
    </script>

    接口编写:

    package jap.shjz.manager;

    import asp.engine.core.manager.BaseManager;
    import asp.engine.util.AppUtil;
    import com.alibaba.fastjson.JSON;
    import com.alibaba.fastjson.JSONArray;
    import com.util.DateUtils;
    import com.util.RowList;
    import com.web.config.annotation.AjaxForm;
    import com.web.config.annotation.AjaxOperation;
    import com.web.frame.Authorize;
    import jos.engine.core.ServiceData;
    import jos.engine.core.jdbc.JdbcTemplate;
    import jos.framework.key.KeyUtils;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Component;

    import java.util.*;

    @Component
    @AjaxForm(model = "randomReviewManager", perm = "login", type = "query")
    public class RandomReviewManager extends BaseManager {
    @Autowired
    private ShjzToDsrManager shjzToDsrManager;

    @AjaxOperation(method = "op_getReviewPerson")
    public void getReviewPerson(ServiceData serviceData) {
    String xzqh = serviceData.getParameter("xzqh");
    int level = xzqh.length() + 2;
    int total = 0;
    ArrayList<Map<String, Object>> arrayList = new ArrayList();
    try {
    RowList rowList = getJdbcTemplate().queryRowList(STATISTICIAN_SQL, new Object[]{level, xzqh, level});
    if (rowList.size() > 0) {
    for (int i = 0; i < rowList.size(); i++) {
    total = total + Integer.parseInt(rowList.get(i).get("count"));
    Map<String, Object> map = new HashMap<>();
    map.put("xzqh", rowList.get(i).get("xzqh"));
    map.put("count", rowList.get(i).get("count"));
    map.put("total", total);
    arrayList.add(map);
    }
    String strJson = JSON.toJSONString(arrayList);
    serviceData.setResponseData(strJson);
    }
    } catch (Exception e) {
    log.error(e);
    }
    }

  • 相关阅读:
    VUE学习笔记--模板渲染
    VUE学习笔记--生命周期 Vue
    VUE学习笔记--实例及选项
    VUE学习笔记--Vue的模板语法
    Vue学习笔记--Vue 简述
    吴裕雄--天生自然--SPRING BOOT--解决:Lifecycle mapping "org.eclipse.m2e.jdt.JarLifecycleMapping" is not available. To enable full functionality, install the lifecycle
    【Vue2.x】Vue UI中无法安装指定版本依赖解决方法
    mysql加锁过程
    java实现交替打印的四种方法
    23th CSP 游记
  • 原文地址:https://www.cnblogs.com/tongcc/p/13691479.html
Copyright © 2011-2022 走看看