Javascript 如何在window.location.replace代码中使用发送帖子信息

Javascript 如何在window.location.replace代码中使用发送帖子信息,javascript,php,jquery,ajax,Javascript,Php,Jquery,Ajax,我的网站是这样工作的: 1.用户输入用户名并通过,然后按提交。 2.提交时,ajax被发送到一个页面,该页面检查信息并回显1、2或3。 3.基于ajax结果,它将用户发送到应用程序窗口 我需要的是:当用户被发送到应用程序窗口时,我希望在post中将用户id粘贴到新地址 <script> $(document).on("click", "#submit", function(event) { var user = document.getElementById("nam

我的网站是这样工作的: 1.用户输入用户名并通过,然后按提交。 2.提交时,ajax被发送到一个页面,该页面检查信息并回显1、2或3。 3.基于ajax结果,它将用户发送到应用程序窗口

我需要的是:当用户被发送到应用程序窗口时,我希望在post中将用户id粘贴到新地址

    <script>
$(document).on("click", "#submit", function(event)
{
    var user = document.getElementById("name").value;
    var pwd = document.getElementById("pwd").value;
    $.post("userExistCheck.php",
    {
        userName: user,
        userPass: pwd
    },
    function(result)
    {
      if (result == "0")
      {
        window.location.replace("Moment/momentApp.php");
      }
      else if (result == "1")
      {
        alert("Password is incorrect!");
      }
      else
      {
        alert("User does not exist!");
      }
    });
})
</script>

$(文档)。在“单击”、“提交”功能(事件)上
{
var user=document.getElementById(“名称”).value;
var pwd=document.getElementById(“pwd”).value;
$.post(“userExistCheck.php”,
{
用户名:user,
用户通行证:pwd
},
功能(结果)
{
如果(结果=“0”)
{
window.location.replace(“Moment/momentApp.php”);
}
否则如果(结果=“1”)
{
警报(“密码不正确!”);
}
其他的
{
警报(“用户不存在!”);
}
});
})
试试这样的方法

我希望这是你想要的,否则就跟着曼塔回答:)

Html

<input type="hidden" id="userid" name="userid" value="1" />
试试这样的方法

我希望这是你想要的,否则就跟着曼塔回答:)

Html

<input type="hidden" id="userid" name="userid" value="1" />

嗨,快换电话

window.location.replace("Moment/momentApp.php?userid=" + userid);

嗨,快换电话

window.location.replace("Moment/momentApp.php?userid=" + userid);

$(文档)。在“单击”、“提交”功能(事件)上
{
var userid=document.getElementById(“userid”).value;
}
因此,基本上你也可以发送用户id。我还没有写完整的代码,但应该附加必要的部分


$(文档)。在“单击”、“提交”功能(事件)上
{
var userid=document.getElementById(“userid”).value;
}
因此,基本上你也可以发送用户id。我还没有写完整的代码,但是应该附加必要的部分