42 lines
1 KiB
JavaScript
42 lines
1 KiB
JavaScript
|
|
class SaveManager {
|
|
|
|
static deleteCategory(id) {
|
|
let data = {
|
|
function: "remove_category",
|
|
data: id,
|
|
};
|
|
console.log(data);
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "save_manager.php",
|
|
data: JSON.stringify(data),
|
|
dataType: "json",
|
|
contentType: "application/json; charset=utf-8",
|
|
complete: function (data) {
|
|
$.alert(data.responseText);
|
|
console.log(data);
|
|
},
|
|
});
|
|
}
|
|
|
|
static async saveCategory(category, isNew) {
|
|
let data = {
|
|
function: isNew ? "create_category" : "update_category",
|
|
data: category,
|
|
};
|
|
|
|
let response = await $.ajax({
|
|
type: "POST",
|
|
url: "save_manager.php",
|
|
data: JSON.stringify(data),
|
|
dataType: "json",
|
|
contentType: "application/json; charset=utf-8",
|
|
});
|
|
console.log(response);
|
|
return response['data'];
|
|
}
|
|
}
|
|
|
|
|
|
|