Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> </head> <body> <form action="path/to/server/script" method="post" id="my_form"> <label>Name</label> <input type="text" name="name" /> <label>Email</label> <input type="email" name="email" /> <label>Website</label> <input type="url" name="website" /> <input type="submit" name="submit" value="Submit Form" /> <div id="server-results"> <!-- For server results --> </div> </form> <script> $("#my_form").submit(function(event) { event.preventDefault(); //prevent default action let post_url = $(this).attr("action"); //get form action url let form_data = $(this).serialize(); //Encode form elements for submission $.post(post_url, form_data, function(response) { $("#server-results").html(response); }); }); </script> </body> </html>