-2

I trying to send two images with ajax (inside submitHandler) after using jquery validator plugin and i don't know hoy i cant take and send this image by ajax.

My code here:

var submitHandler = function(form) {

    var formData = form[0];
    var formData = new FormData(formData);

    $.ajax({
        url: 'function/savePreInscripcion.php',
        type: 'POST',
        data: formData,
        mimeType: "multipart/form-data",
        contentType: false,
        cache: false,
        processData: false,
        success: function(data){
            alert(data);
        }
    });
};

but this dont work..

this display this error:

TypeError: Argument 1 of FormData.constructor does not implement interface HTMLFormElement.
var formData = new FormData(formData);

so.. what's worng here?

Thnx for the help!,

1

1 Answer 1

-1

I resolve this..

Just change a little party on my code..

var submitHandler = function(form) {
    $.ajax({
        url: 'function/savePreInscripcion.php',
        type: 'POST',
        data: new FormData(form),
        mimeType: "multipart/form-data",
        contentType: false,
        cache: false,
        processData: false,
        success: function(data){
            alert(data);
        }
    });
};

Just I change the call to the form and put this directly on the data whit the next code: "data: new FormData(form)" and it work fine! =)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.