Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery PHP Ajax检查登录显示模式的用户_Javascript_Php_Jquery_Ajax - Fatal编程技术网

Javascript jQuery PHP Ajax检查登录显示模式的用户

Javascript jQuery PHP Ajax检查登录显示模式的用户,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,我有jQuery PHP Ajax来检查用户是否登录 JS PHP 我尝试了上面的代码正在工作,但在注销后显示multipe模式,直到我刷新页面。我只想模式显示一次。使用函数而不是setInterval使用函数而不是setInterval jQuery(document).ready(function() { setInterval(function() { jQuery.ajax({ url: 'chkLoggedin.php', type: 'POST', s

我有jQuery PHP Ajax来检查用户是否登录

JS

PHP

我尝试了上面的代码正在工作,但在注销后显示multipe模式,直到我刷新页面。我只想模式显示一次。

使用函数而不是
setInterval
使用函数而不是
setInterval

jQuery(document).ready(function()
{
setInterval(function()
{
    jQuery.ajax({
    url: 'chkLoggedin.php',
    type: 'POST',
    success:function(response)
    {
        if(response == "sessionExpired")
        {
            bootbox.dialog(
            {
                message: "Please login to continue",
                title: "Not logged in",
                buttons:
                {
                    success:
                    {
                        label: "Log in",
                        className: "btn-success",
                        callback: function()
                        {
                            $('.bootbox').modal('hide');
                        }
                    }
                }
            });
            return false;
        }
    }
});
}, 5000);
});
require("config/db.php");
session_start();
include("config/session.php");

if(empty($session))
{
    echo "sessionExpired";
}