WordPress send Ajax where click button

@sergio

Here is the working answer you can check if there is still any issue paste it here and it if it works well you can upvote the answer to help others.

The issue it when you click button your $(this).prop(‘files’)[0] is not working because not this scope to the button element.

$('body').on('click', '#enviar_fichero', function() {
        $this = $(this);
        var appt_id=document.getElementById('appt_id').value;
        file_data = jQuery('#file').prop('files')[0];
        form_data = new FormData();
        form_data.append('file', file_data);
        form_data.append('action', 'custom_ajax_booked_upload_files');
        form_data.append('appt_id', appt_id);
         
        $.ajax({
             url: ajax_var.url,
             type: 'POST',
             contentType: false,
             processData: false,
             data: form_data,
             success: function (response) {
                alert(response);
            }
      });
});  

casinojojobetpulibet girişOnwin Güncel Giriştürkçe altyazılı pornocanlı bahis casinocanlı bahis casino siteleriOnwin Güncel Girişcasinoholiganbet girişholiganbet güncel giriş