63 lines
1.7 KiB
JavaScript
63 lines
1.7 KiB
JavaScript
|
|
$("#tabel_data_naskah").DataTable({
|
|
"stateSave": true,
|
|
"paging": true,
|
|
"lengthChange": true,
|
|
"searching": true,
|
|
"ordering": false,
|
|
"info": true,
|
|
"autoWidth": false
|
|
});
|
|
|
|
$(document).on("click", "#tmbh_naskah", function () {
|
|
var id = 0;
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "app/master/naskah_dinas/modal.php",
|
|
data: {
|
|
id: id,
|
|
},
|
|
success: function (data) {
|
|
$('#modal_naskah').modal('show');
|
|
$('#modal_body_naskah').html(data);
|
|
}
|
|
});
|
|
});
|
|
|
|
$("#simpan_naskah").click(function () {
|
|
var formData = new FormData($('#form_naskah')[0]);
|
|
|
|
formData.append('id',$('#naskah_id').val());
|
|
formData.append('nama', $('#nama_file').val());
|
|
formData.append('file_naskah', $('#file_naskah')[0].files[0]);
|
|
formData.append('key', 'simpan_naskah');
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "app/master/naskah_dinas/controller.php",
|
|
data: formData,
|
|
processData: false, // Important to prevent jQuery from processing the data
|
|
contentType: false, // Important to prevent jQuery from setting contentType
|
|
success: function (response) {
|
|
var result = JSON.parse(response);
|
|
infoToast(result.icon,result.message);
|
|
$('#modal_naskah').modal('hide');
|
|
$('#modal_body_naskah').html();
|
|
$('#tabel_naskah').load('app/master/naskah_dinas/table.php');
|
|
|
|
},
|
|
error: function (xhr, status, error) {
|
|
console.error('AJAX request failed:', status, error);
|
|
}
|
|
});
|
|
});
|
|
|
|
function infoToast(icone, infone) {
|
|
Swal.fire({
|
|
// position: posisine,
|
|
icon: icone,
|
|
title: infone,
|
|
showConfirmButton: false,
|
|
timer: 2500
|
|
});
|
|
} |