请教各位大侠PHP问题
admin 发表于 2010-07-18 | 来源:互联网 | 阅读:

在PHP里面怎么做无刷新效果

已经有10 个评论
  1. 421056 说:

    什么是无刷新效果?描述具体点

  2. 天天累 说:

    …………………………….

  3. xiaobao520 说:

    我猜你是想要ajax吧……跟php关系,不大

  4. weiwei 说:

    无刷新得用ajax.js做获取,php做后端数据处理

  5. jc2008_828 说:

    无刷新用ajax(主要成分js)

  6. doing7 说:

    我就是想用php联系Ajax做无刷新,可是我不会Ajax,怎么办

  7. look 说:

    是在Javascript里写吗?能帮我下个示例吗?谢谢了!

  8. jc2008_828 说:

    下面的例子来自http://www.w3schools.com/ajax/ajax_examples.asp这个网站有很多Web开发的简易教程JScript code
    <html>
    <head>
    <script type="text/javascript">
    function loadXMLDoc(url,cfunc)
    {
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=cfunc;
    xmlhttp.open("GET",url,true);
    xmlhttp.send();
    }

    function myFunction()
    {
    loadXMLDoc("ajax_info.txt",function()
    {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
    });
    }
    </script>
    </head>
    <body>

    <div id="myDiv"><h2>Let AJAX change this text</h2></div>
    <button type="button" onclick="myFunction()">Change Content</button>

    </body>
    </html>

  9. nrc001 说:

    PHP code
    <?php
    //abc.php
    if($_GET){
    echo $_GET['text'];
    }else if($_POST){
    echo $_POST['text'];
    }else{
    echo $_REQUEST['text'];
    }
    ?>

    <input type="text" id="text" value="我是中国人">
    <input type="button" name="button" value="myAjax" onclick="post_test()">

    <script language="javascript">
    var request;
    function createxmlHttpRequest(){//判断浏览器类型,创建xmlHttpRequest对象
    if(!request){
    if(window.XMLHttpRequest){
    request = new XMLHttpRequest();
    }else{
    request = new ActiveXObject("Microsoft.XMLHTTP");
    }
    }
    }
    /*
    function get_test(){//get发送模式
    createxmlHttpRequest();
    var url = "abc.php?text=" + encodeURI(document.getElementById("text").value);
    request.open("get", url, true);
    request.onreadystatechange = callback;
    request.send(null);
    }
    */
    function post_test(){//post发送模式
    createxmlHttpRequest();
    var url = "abc.php";
    var send = "text=" + encodeURI(document.getElementById("text").value);
    request.open("post", url, true);
    request.onreadystatechange = callback;
    request.setRequestHeader("content-type", "application/x-www-form-urlencoded");
    request.send(send);
    }

    function callback(){//回调函数
    if (request.readyState == 4){
    if (request.status == 200){
    alert(request.responseText);
    }else if(request.status == 404){
    alert("该路径未找到");
    }else if(request.status == 403){
    alert("禁止访问");
    }else{
    alert("status is " + request.status);
    }
    }
    }
    </script>

  10. water20042 说:

    用jquery吧,已经封装好了,方便你理解

我要评论

评论功能因故关闭!

请加入我们的QQ群一起参与讨论:群号59400482(500人超级群)


返回首页 | 关于我们 | 联系我们 | 广告合作 | 网站地图 | 友情链接 | 版权声明