在JAVASCRIPT中使用PHP会话?

时间:2017-02-14 18:16:51

标签: javascript php session

这是有效的:

var ts="<?php $auto[0]=$_SESSION['auto'];$auto[1]=1;?>";

这不起作用:

var ts="<?php $auto[0]=$_SESSION['auto'];$auto[1]=$_SESSION['auto'];?>";

帮帮我

1 个答案:

答案 0 :(得分:0)

var o;
    function changementEtat(){
        if(o.readyState==4) {
            var text = o.responseText;
            //alert(text);
            var ts="<?php $auto[0]=$_SESSION['auto'];$auto[1]=$_SESSION['auto'];?>";


        }
    }

    function tester() {
            var abc=3;

            modal.style.display = "none";

            o = new XMLHttpRequest();
            o.open('POST',"ajax.php",true);
            o.onreadystatechange =changementEtat;
            o.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            o.send("tfu="+abc);



        document.getElementById("tester").innerHTML="<?php $table=$tableau->nextTable($table,1,$auto); echo $tableau->tableToString2($table,Null); ?>";
        styler();
        modal.style.display = "block";
    }