bludit/bl-plugins/backup/js/backup.js

36 lines
918 B
JavaScript
Raw Normal View History

jQuery(document).ready(function($) {
$('#backupFile').change(function() {
var file = this.files.length >= 1? this.files[0]: null;
2020-05-14 17:59:29 +02:00
if (file === null) {
return false;
}
// Build Form Data
var url = $('#jsform').attr("action") || window.location.href;
var form = new FormData();
form.append("tokenCSRF", $('[name="tokenCSRF"]').val());
form.append("backupFile", file);
// Apply Form
$.ajax({
url: url,
data: form,
type: "POST",
dataType: "json",
mimeType: "multipart/form-data",
contentType: false,
processData: false,
2020-05-14 17:59:29 +02:00
error: function (jqXHR, status, error) {
var data = jqXHR.responseJSON;
var alert = $("<div></div>").addClass("alert alert-danger").text(data.message);
$("#jsform .alert:not(.alert-primary)").remove();
$("#jstokenCSRF").after(alert);
},
2020-05-14 17:59:29 +02:00
success: function (data, status, jqXHR) {
window.location.reload();
}
});
});
});