post multipart/form-data with ajax

272 views Asked by At

I want to post my form by ajax, the form contains some text fields and one file field, I used bootstrapValidator to validate the form, here is my code:

ajax:

$('#profile').bootstrapValidator({

        // some validations here

    }).on('success.form.bv', function(e) {

        e.preventDefault();

        var $form = $(e.target),                        // The form instance
        bv  = $form.data('bootstrapValidator');   // BootstrapValidator instance

        var formData = new FormData($form);

        $.post('index.php', formData, function(response) {
...

but the post request didn't sent, so where is the error in my code?

0

There are 0 answers