通过轮询实现消息弹窗提醒

Html





    
    State_Restart
    



    
通知

系统将在1分钟后重启,请保存好当前操作!!!


JavaScript

$(document).ready(function () {
    var t = setInterval(function () { 
    $.post("/Notice/State", function (a) {
            if (a == "1") {
                //iframe窗
                layer.open({
                    type: 2,
                    title: false,
                    closeBtn: 1, //不显示关闭按钮
                    shade: [0],
                    shadeClose: true,
                    area: ['340px', '215px'],
                    offset: 'rb', //右下角弹出
                    time: 3000, //2秒后自动关闭
                    anim: 2,
                    content: ['/Notice/State_Restart', 'no'],//iframe的url,no代表不显示滚动条
                });
               // clearInterval(t);
            }
            else {
                // alert("2");
            }
        });
    },15000);
});

Controller

public void State()
        {
            var result = sql.NOTICE.Where(r => r.STATE == "1");
            if (result.Count() == 1)
            {
                Response.Write("1");
            }
            else
            {
                Response.Write("0");
            }
        }


你可能感兴趣的:(mvc,asp.net)