php一个页面内 能不能监视 session变化啊该如何解决

WBOY
Release: 2016-06-13 13:28:55
Original
821 people have browsed it

php一个页面内 能不能监视 session变化啊
就是我用一个while 如果session等于指定的值的话 就返回结果 可是不行啊 很郁闷 

是不是php在创建页面时session就赋值了 session再变化必须得刷新页面啊

------解决方案--------------------
是的,当session值改变后,你必须刷新页面才能看到新的值
但你可以这样做 用AJAX 就可以时时得到某个值了 如

JScript code

//定时间执行
$(document).ready(function(){
    function autoAlt(){
        //alert("bb");
        $.post("ajax.php?act=memo",
               {act:"memo"},
               function(redata){
                if(redata!=""){
                                    alert(redata);
                },
               "text")
    }
    
    setInterval(autoAlt,1000);
}) <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template