Input Images with Dropzone in AJAX request

Asked

Viewed 58 times

0

I have a problem with my code referring to trying to perform an image input via AJAX.

The PHP script is ok, because the same code is used in other operations, but I believe there is something wrong with my javascript code.

HTML

<form>
    <div class="form-group" id="selecionarDoc">
        <label for="file">Selecione a imagem</label>
        <form action="https://endpoint/apis.php" class="dropzone dz-clickable" id="MyDropzone">
            <div class="dz-default dz-message">
                <span><i class="material-icons icon-2x text-primary mb-4">cloud_upload</i></span>
            </div>
    </div>
    <div class="form-group">
        <a href="javascript:void(0)" class="btn btn-block btn-primary btn-lg rounded border-0 z-3" id="btnSubmit">Cadastrar</a>
    </div>
</form>

JAVASCRIPT

$(document).on('click', '#btnSubmit', function() {
    $.ajax({
        url: "https://endpoint/apis.php",
        action: 'cadastraFotos',
        success: function(data) {
            Alert(data);
        }
    });
});

It seems that the code does not even arrive at the server, because nothing returned to me in the console.

  • if the php code is already used in other applications, did you compare the calls? is a post or get?

  • I have already done the test in the form GET and POST... and below the url of ajax, also passed the method, but it did not work.

  • implements an error Handler in your ajax to see what is happening, like this: error: function (xhr, ajaxOptions, thrownError) { .... inspecioana os parametros }

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.