- moving ajax script outside plugin class, as a js file

- wip trying to use the wordpress image editor
This commit is contained in:
asus
2024-02-19 00:46:03 +01:00
parent e9032647f2
commit 04c4ea31d5
9 changed files with 97 additions and 105 deletions

View File

@@ -0,0 +1,19 @@
/**
* function that create an ajax post action
* - PLGNTLS_data.ajax_nonce and PLGNTLS_data.ajax_url
* are passed from the class PLGNTLS_class
*/
console.log("PLGNTLS_data");
console.log(PLGNTLS_data);
function PLGNTLS_ajax(data_key, data_value, action) {
const data = new FormData();
data.append("action", action);
data.append("_ajax_nonce", PLGNTLS_data.ajax_nonce);
data.append(data_key, data_value);
return fetch(PLGNTLS_data.ajax_url, {
method: "POST",
credentials: "same-origin",
body: data
});
}