Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- Form submit with AJAX passing form data to PHP without page refresh -->
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>Ajax Form Submit Example</title>
- <script src="js/jquery-1.10.2.js"></script>
- <script>
- $(function() {
- $('form').on('submit', function(e) {
- $.ajax({
- type : 'post',
- url : 'post.php',
- data : $('form').serialize(),
- success : function() {
- alert('Form was submitted');
- }
- });
- e.preventDefault();
- });
- });
- </script>
- </head>
- <body>
- <form>
- <input name="name" value="" required="">
- <br>
- <input name="password" value="" required="">
- <br>
- <input name="submit" type="submit" value="Submit">
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment