weixin_33695082 2015-12-25 13:15 采纳率: 0%
浏览 20

请在Ajax中等待消息

I am little new in ajax and js. I am trying to send the data to functions.php?action=signp but the code says "please wait" and then nothing happens. My code is given below:

<script type="text/javascript">
function signup()
{
    var ufname = document.getElementById("fName").value;
    var ulname = document.getElementById("lName").value;
    var e = document.getElementById("email").value;
    var p1 = document.getElementById("pass1").value;
    var p2 = document.getElementById("pass2").value;
    var status = document.getElementById("statusSignUp");
    if(ufname == "" || ulname == "" || e == "" || p1 == "" || p2 == "")
    {
        status.innerHTML = "Fill out all of the form data";
    }
    else
    {
        document.getElementById("signupbtn").style.display = "none";
        status.innerHTML = 'please wait ...';
        var ajax = ajaxObj("POST", "functions.php?action=signp");
        ajax.onreadystatechange = function()
        {
            if(ajaxReturn(ajax) == true)
            {
                if(ajax.responseText != "signup_success")
                {
                    status.innerHTML = ajax.responseText;
                    document.getElementById("signupbtn").style.display = "block";
                } 
                else
                {
                    window.scrollTo(0,0);
                    document.getElementById("signupform").innerHTML = "Yippieeee";
                }
            }
        }
        //xhttp.open("POST", "functions.php?action=signp", true);
        ajax.send("&fName="+fName+"&lName="+lName+"&email="+email+" pass1="+pass1);
    }
}
</script>

Someone please tell me is there anything wrong in the code?

  • 写回答

2条回答 默认 最新

  • weixin_33744854 2015-12-25 13:25
    关注

    I would give you a very easy solution for this. Use jQuery Ajax. Its a very easy library to use.

    http://api.jquery.com/jquery.ajax/

    评论

报告相同问题?

悬赏问题

  • ¥20 树莓派5做人脸情感识别与反馈系统
  • ¥15 selenium 控制 chrome-for-testing 在 Linux 环境下报错 SessionNotCreatedException
  • ¥15 使用pyodbc操作SQL数据库
  • ¥15 MATLAB实现下列
  • ¥30 mininet可视化打不开.mn文件
  • ¥50 C# 全屏打开Edge浏览器
  • ¥80 WEBPACK性能优化
  • ¥30 python拟合回归分析
  • ¥500 metaswitch 6010
  • ¥15 关于#分类#的问题:不用人工智能的算法