Autodesk
Autodesk

Reputation: 711

bootstrapValidator ajax submit error "404 Page Not Found"

<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!

Upvotes: 0

Views: 471

Answers (1)

Autodesk
Autodesk

Reputation: 711

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>

Upvotes: 1

Related Questions