57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
|
|
class AjaxManager {
|
|
|
|
static async getCategories() {
|
|
let data = {
|
|
type: 'category',
|
|
action: 'get',
|
|
};
|
|
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'];
|
|
}
|
|
|
|
static async deleteCategory(id) {
|
|
let data = {
|
|
type: 'category',
|
|
action: 'remove',
|
|
data: id,
|
|
};
|
|
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['status'];
|
|
}
|
|
|
|
static async saveCategory(category, isNew) {
|
|
let data = {
|
|
type: 'category',
|
|
action: isNew ? 'create' : 'update',
|
|
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'];
|
|
}
|
|
}
|
|
|
|
|
|
|