Closed. This question needs to be more focused。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题。
                        
                        5年前关闭。
                                                                                            
                
        
我有这张注册表。如何在不将用户重定向到action.php的情况下将输入信息发送到action.php,然后将其重定向回此页面。我希望表格在后台提交。

<p id="message"></p>
<form action='action.php' method='post'>
Username: <input type='text' name='username'>
Password: <input type='password' name='password'>
e-mail: <input type='text' name='email'></div>
<input type='submit' value='Register' onclick='Submit()' />
</form>
<script>
function Submit(){
document.getElementById("message").innerHTML = "You have been successfully registered";
}
</script>


谢谢!

最佳答案

http://api.jquery.com/jquery.post/
应该可以帮助您,这是一个示例,可以与您发布的代码一起使用。

var data = $('form').serialize();
$.post( "action.php", data, function() {
    $('#message').text('You have been successfully registered');
})

关于javascript - 如何在不离开页面的情况下发送表格? ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21784560/

10-09 09:53