- forget old ajax wp, now use fetch wp
- trying js files without imports
This commit is contained in:
@@ -8,20 +8,25 @@
|
||||
// OLD VERSION
|
||||
console.log("PLGNTLS_data");
|
||||
console.log(PLGNTLS_data);
|
||||
*/
|
||||
function PLGNTLS_ajax(action, data_obj) {
|
||||
const data = new FormData();
|
||||
data.append("action", action);
|
||||
data.append("_ajax_nonce", PLGNTLS_data.ajax_nonce);
|
||||
for (const key in data_obj)
|
||||
data.append(key, data_obj[key]);
|
||||
// for (const key in data_obj)
|
||||
// {
|
||||
// data.append(key, data_obj[key]);
|
||||
// }
|
||||
// console.log("data:", data);
|
||||
data.append(data_obj);
|
||||
|
||||
return fetch(PLGNTLS_data.ajax_url, {
|
||||
method: "POST",
|
||||
credentials: "same-origin",
|
||||
body: data,
|
||||
hedears: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
// https://stackoverflow.com/q/52657814/9497573
|
||||
function is_plain_object(obj)
|
||||
@@ -35,6 +40,7 @@ function is_plain_object(obj)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
function PLGNTLS_fetch(src = null, options = null)
|
||||
{
|
||||
if (src === null)
|
||||
@@ -108,3 +114,4 @@ function PLGNTLS_fetch(src = null, options = null)
|
||||
|
||||
return fetch(PLGNTLS_data.ajax_url, options);
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user