Last active
December 15, 2015 07:59
-
-
Save rturowicz/5227770 to your computer and use it in GitHub Desktop.
JQuery forms
This file contains 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
// basic | |
$(document).ready(function() { | |
$('#contact').ajaxForm(function() { | |
alert("Thank you for your comment!"); | |
}); | |
}); | |
<form action="/" method="post" id="contact"> | |
</form> | |
// advanced | |
$(document).ready(function() { | |
var options = { | |
target: '#output1', // target element(s) to be updated with server response | |
beforeSubmit: showRequest, // pre-submit callback | |
success: showResponse // post-submit callback | |
//url: url // override for form's 'action' attribute | |
//type: type // 'get' or 'post', override for form's 'method' attribute | |
//dataType: null // 'xml', 'script', or 'json' (expected server response type) | |
//clearForm: true // clear all form fields after successful submit | |
//resetForm: true // reset the form after successful submit | |
// $.ajax options can be used here too, for example: | |
//timeout: 3000 | |
}; | |
$('#contact').ajaxForm(options); | |
}); | |
<form action="/" method="post" id="contact"> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment