• 定时器传参数


    定时器
    setTimeout() 和 setInterval() 在使用函数名作为调用句柄是都不能带参数,因此定义一个函数_checkMsg(),返回一个不带参数的函数,在
    这个函数内部调用外部函数checkMsg(),不需使用参数。
    setInterval(_checkMsg(isLogin),1000);
     
    function checkMsg(uid){
           $.ajax
              ({
                   type: "post",
                   url: "ajax_process.php?action=unread",
                   dataType: "json",
                   data: {"isLogin":uid},
                   success: function(json)
                   {
                     if(json.success == 1)
                       {
                          $('#new_message').fadeIn();
                       }else
                       {
                            $('#new_message').fadeOut();
                        }
                   }
                });
         }
     
         function _checkMsg(uid){
            return function(){
              checkMsg(uid);
            }
         }
  • 相关阅读:
    xunjian.sh
    192.168.50.235配置
    自动备份并删除旧日志
    bg和fg命令
    linux之sed用法
    正则表示第二行,第二列
    linux下redis安装
    Hma梳理
    linux 系统监控、诊断工具之 lsof 用法简介
    java的基本数据类型有八种
  • 原文地址:https://www.cnblogs.com/chuangweili/p/5160154.html
Copyright © 2020-2023  润新知