<script>
$(document).ready(function() {
$("#myform")
.bootstrapValidator(/*validate options*/)
.on('success.form.fv', function(e) {
e.preventDefault();
submit();
});
});
function submit() {
$('form').on('submit', function() {
$.ajax({
type : 'post',
url : './ajax/ajaxSubmit.php',
data : $('form').serialize(),
success : function(result) {
alert('form was submitted');
}
});
});
}
</script>
<form id="myform" method="post"></form>
<button type="submit">ok</button>
When I press submit button,then it goes "404 Page Not Found" error; But I don't know what's wrong with the code?
I have no problem on validate, but on ajax submit, thanks!
Finally,it works! There is an answer.
But I still have no idea why it went wrong :(
<script>
$(document).ready(function() {
$("#myform")
.bootstrapValidator(/*validate options*/);
$('#myform')
.on('success.form.bv', function(e) {
e.preventDefault();
submit();
});
});
function submit() {
$.ajax({
type : 'post',
url : './ajax/ajaxSubmit.php',
data : $('form').serialize(),
success : function(result) {
alert('form was submitted');
}
});
}
</script>
<form id="myform" method="post"></form>
<button type="submit">ok</button>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.