makkus makkus - 6 months ago 38
Javascript Question

My ajax process is repeating at dropzone js

I need some detail with image in the database. I am using dropzone js for upload. Problem happening when I execute more than one to ajax. After the first execute, each time its adding same data once again. dropzone working correctly

first post adding one data -
second post adding two data -
third post adding three data

Dropzone.options.seferekle = {
paramName: "file",
parallelUploads : 1,
acceptedFiles: '.jpg,.jpeg,.JPEG,.JPG,.png,.PNG',
autoProcessQueue : false,
addRemoveLinks : true,
init: function() {

myDropzone = this;

$('.post').on('click', function(event){

tarih = $("input[name=tarih]").val();

alert("Sefer Tarihi ve Sefer Türü Alanları Boş Bırakılamaz.");

myDropzone.on("success", function(file, responseText) {
newImgName= responseText;

url: "http://localhost/vipumre/App/Model/add.php",
data: "image_name="+newImgName+"&tarih="+tarih,
type: "post",

success: function(data) {

error: function() {
$('.return').text("Ajax Error");

}); //Ajax End

myDropzone.on("complete", function(file,done) {




} //Dropzone init End

}; //Dropzone End


If you want to send data while you uploading your files you should use the sending event :

Dropzone.options.seferekle = {

    init: function (e) {

        var myDropzone = this;

        // Event to send your custom data to your server
        myDropzone.on("sending", function(file, xhr, data) {

            // First param is the variable name used server side
            // Second param is the value, you can add what you what
            // Here I added an input value
            data.append("your_variable", $('#your_input').val());