我刚接触php,想请教一下大家一个问题,PHP可不可以无刷新保存页面数据?

解决方案 »

  1.   

    AJAX,嗯,有没有一些简单代码参考一下
      

  2.   

    用jquery之类的js框架,查相关手册。很简单的
      

  3.   

    JQuery AJAX 这个一个小时就能用了。
      

  4.   

    function send()
    {document.getElementById("status").style.display='block';
    document.body.style.cursor='wait'; 
    document.getElementById("submit").disabled = true;var postStr = "";
    postStr = postStr + "&username="+escape(document.getElementById("username").value);
    postStr = postStr + "&email="+document.getElementById("email").value;
    postStr = postStr + "&act=publishlove";$.ajax(
    {
    type: "POST", 
    contentType:"application/x-www-form-urlencoded",
    url: "/b.php", 
    data: postStr, 
    error: function(){ 
    alert('您所请求的页面有异常,请刷新重试。');
    document.getElementById("status").style.display='none';
    document.body.style.cursor='auto'; 
    document.getElementById("submit").disabled = false;
    },
    success: function(msg){
    if (msg =="")
    {
    alert("发布成功!");
    document.getElementById("status").style.display='none';
    document.body.style.cursor='auto'; 
    document.getElementById("submit").disabled = false;
    document.location= "/walls.asp?wn="+document.getElementById("wallname").value;
    }
    else
    {
    alert(  msg ); 
    document.getElementById("status").style.display='none';
    document.body.style.cursor='auto'; 
    document.getElementById("submit").disabled = false;
    } } 
    });}
    贴一段js代码