其他分享
首页 > 其他分享> > 第十三周

第十三周

作者:互联网

php语言开发淘宝系统

php可以实现页面实时更新,轻量化编程,相比于jsp。

可以通过js调用php文件返回数据

    <script type="text/javascript" language="JavaScript">
        function showSite()
        {
            // if (str=="")
            // {
            //     document.getElementById("txtHint").innerHTML="";
            //     return;
            // }
            if (window.XMLHttpRequest)
            {
                // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
                xmlhttp=new XMLHttpRequest();
            }
            else
            {
                // IE6, IE5 浏览器执行代码
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange=function()
            {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
                }
            }
            xmlhttp.open("GET","../getsite_mysql.php?q=<?php echo $_GET['value']?>",true);
            xmlhttp.send();
        }
    </script>

设置接受数据显示的地方

<div id="txtHint"><b></b></div>

可以采用GET或POST传输数据

        session_start();

开服务器session,页面可以设置session数据或者获取seesion

jq使用ajax

function fun(n) {
    var value = document.getElementById("suosou").value;
    $.ajax(
        {
            url:"server.php",           //the page containing php script
            type: "POST",               //request type
            data:{action: value},
            success:function(result){
                window.location.href = 'shouye.php?value='+value;
                alert("成功");
            }
        });
}

 

标签:function,xmlhttp,第十三,value,getElementById,session,php
来源: https://www.cnblogs.com/weidewozi/p/14914242.html