submit jquery code example
Example 1: jQuery AJAX form submit
$("#myFormID").submit(function(e) {
e.preventDefault();
var form = $(this);
var url = form.attr('action');
$.ajax({
type: "POST",
url: url,
data: form.serialize(),
success: function(data){
console.log(data);
}
});
});
Example 2: jquery submit form
$('form').submit();
$('form').submit(function(e){
e.preventDefault();
e.currentTarget.submit();
});
Example 3: jquery form id submit
$(document).ready(function(){
$("#submitBtn").click(function(){
$("#myForm").submit();
});
});
Example 4: when a form is subbmited jquery
$("#myform").submit(function(e) {
})
Example 5: jquery submit form
<input type='button' value='Submit form' onClick='submitDetailsForm()' />
<script language="javascript" type="text/javascript">
function submitDetailsForm() {
$("#formId").submit();
}
</script>
Example 6: submit form jquery browser check
var $myForm = $('#myForm');
if(! $myForm[0].checkValidity()) {
$myForm.find(':submit').click();
}