jeudi 28 février 2019

Ajax remove link on Dropzone Laravel POST data empty result

I created multiple upload with Dropzone, and added remove link with ajax request but when I did echo json_encode($_POST); here the POST data result was empty. Anyone have any solution ?

here is my following code :

var token = $('[name=_token').val();
    Dropzone.autoDiscover = false;
    var imageUpload= new Dropzone(".dropzone",{
        url: "",
        maxFilesize: 2,
        method:"post",
        acceptedFiles:"image/*",
        paramName:"image",
        dictInvalidFileType:"Type file ini tidak dizinkan",
        addRemoveLinks:true,
        headers : {
            'X-CSRF-Token' : token
        }
    });

    //Event ketika Memulai mengupload
    imageUpload.on("sending",function(file, xhr, formData){
        var token_upload = 1337;
        formData.append("token_upload" , token_upload);
    });

    imageUpload.on("removedfile",function(formData){
        $.ajax({
            data    : { "token_upload":1337 },
            type    : "POST",
            url     : "",
            cache   : false,
            processData: false,
            contentType: false,
            dataType: 'json',
            beforeSend: function (request) {
                return request.setRequestHeader('X-CSRF-Token', "");
            },
            success: function(data)
            {
                console.log("Foto terhapus");
            },
            error: function()
            {
                console.log("Error");
            }
        });
    });



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire