ajax

ajax_form

jQuery AJAX submit form

Another similar solution using attributes defined on the form element:
<form id="contactForm1" action="/your_url" method="post">
<!-- Form input fields here (do not forget your name attributes). -->
</form>

<script type="text/javascript">
var frm = $('#contactForm1');

frm.submit(function (e) {

e.preventDefault();

$.ajax({
type: frm.attr('method'),
url: frm.attr('action'),
data: frm.serialize(),
success: function (data) {
console.log('Submission was successful.');
console.log(data);
},
error: function (data) {
console.log('An error occurred.');
console.log(data);
},
});
});
</script>

website

jquery form
https://github.com/jquery-form/form#download

jquery ajax submit form
https://stackoverflow.com/questions/1960240/jquery-ajax-submit-form

发表评论

邮箱地址不会被公开。 必填项已用*标注