- moving ajax script outside plugin class, as a js file
- wip trying to use the wordpress image editor
This commit is contained in:
19
plugins/fipfcard_plugin/utils/plugin_ajax.js
Normal file
19
plugins/fipfcard_plugin/utils/plugin_ajax.js
Normal 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
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user