changed add_var_to_front back to using add_inline instead as localize, because need to not overwrite the variables
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
/*
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
*/
|
||||
function ajax_post(mydata, action, callback_response, callback_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', php_data.nonce);
|
||||
data.append('data', mydata);
|
||||
data.append('_ajax_nonce', nonce);
|
||||
data.append('data', ajax_data);
|
||||
console.log("data: ");
|
||||
console.log(data);
|
||||
|
||||
fetch(php_data.ajax_url, {
|
||||
fetch(ajax_url, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
body: data
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
|
||||
const title = document.querySelector(".first_el_to_change");
|
||||
title.innerHTML = "--- coucou ;) " + php_data.myvar_1;
|
||||
console.log(php_data);
|
||||
title.innerHTML = "--- coucou ;) " + myvar_1;
|
||||
|
||||
const ajax_button_1 = document.querySelector("#test_ajax_1");
|
||||
console.log("ajax_button_1: ");
|
||||
console.log(ajax_button_1);
|
||||
ajax_button_1.addEventListener('click', () => {
|
||||
ajax_post(ajax_button_1, 'get_data');
|
||||
});
|
||||
|
||||
@@ -3,6 +3,5 @@ const sendButton = document.getElementById('mybutton');
|
||||
|
||||
sendButton.addEventListener('click', () => {
|
||||
const inputValue = inputElement.value;
|
||||
|
||||
ajax_post(inputValue, 'get_data');
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
const title3 = document.querySelector(".third_el_to_change");
|
||||
title3.innerHTML = "--- bye bye, " + php_data.myvar_2;
|
||||
console.log(php_data.myvar_2);
|
||||
title3.innerHTML = "--- bye bye, " + myvar_2;
|
||||
console.log(myvar_2);
|
||||
|
||||
Reference in New Issue
Block a user