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

解决方案 »

  1.   

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

  2.   

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

  3.   

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

  4.   

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

  5.   

    下面的例子来自http://www.w3schools.com/ajax/ajax_examples.asp
    这个网站有很多Web开发的简易教程
    <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>
      

  6.   

    <?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>
      

  7.   

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