Created
May 19, 2017 00:30
-
-
Save mrpatg/bf2dbd9717e8e07a50c48d5c397361dc to your computer and use it in GitHub Desktop.
jquery submit form pt2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $('#create').submit(function() { // stop the form's submit event | |
| $.ajax({ // create a new AJAX call | |
| data: $(this).serialize(), // grab all values/data from the form and prep it | |
| type: $(this).attr('method'), // GET or POST | |
| url: $(this).attr('action'), // the file to request, can be local or remote | |
| success: function(response) { // on success | |
| $('#results').html(response); // update the contents of the element. | |
| } | |
| }); | |
| return false; // cancel original event to prevent form submitting | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment