using wp_localize instead of wp_add_line for ajax
This commit is contained in:
@@ -1,17 +1,15 @@
|
||||
/*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
function that create an ajax post action
|
||||
it can be "overloaded" with a callback_response and _error
|
||||
*/
|
||||
function ajax_post(ajax_data, action, callback_response, callback_error) {
|
||||
console.log("in ajac_post, ajax_data :");
|
||||
console.log(ajax_data);
|
||||
const data = new FormData();
|
||||
data.append('action', action);
|
||||
data.append('_ajax_nonce', nonce);
|
||||
data.append('_ajax_nonce', wp_ajax._nonce);
|
||||
data.append('data', ajax_data);
|
||||
console.log("data: ");
|
||||
console.log(data);
|
||||
|
||||
fetch(ajax_url, {
|
||||
fetch(wp_ajax._url, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
body: data
|
||||
|
||||
Reference in New Issue
Block a user