0
点赞
收藏
分享

微信扫一扫

PHP学习11:触发事件前,如何先判断用户是否登录?

mafa1993 2022-04-05 阅读 86
php

触发事件前,如何先判断用户是否登录?

登录了,才可以触发事件,比如——提交表单等事件。

否则,提醒用户先登录!

surepublish.onclick=function(){
            // alert(myquestion.value);
            // alert(landid);
            // var isuser = 0;
            
            var isuser=0<?php echo $uid; ?>;

            // alert(isuser);
            if(!isuser){
                alert('请先登录!');
            }else{
                var xhr=null;
                xhr=new XMLHttpRequest();
                xhr.open("get","landscape_qa.php?content="+myquestion.value+"&landid="+landid,true);
                xhr.send();
                
                xhr.onreadystatechange = function(){
                      if(xhr.readyState == 4){
                        // alert(xhr.responseText);
                        jiazai.innerHTML=xhr.responseText;
                        myquestion.value="";
                      }
                }
            }
     
            
        }

本人想到的一个可能不怎么好,但是能实现的方法。

等我掌握了正确姿势……以后会慢慢优化。 

写一帖以防自己下次还要用。

举报

相关推荐

0 条评论