wip found how to theorically get ajax request in php but for the moment i get error 400

This commit is contained in:
asus
2024-02-10 02:22:16 +01:00
parent 1e88b2c2f6
commit f1f04c4f12
6 changed files with 41 additions and 27 deletions

View File

@@ -0,0 +1,18 @@
const inputElement = document.getElementById('mytext');
const sendButton = document.getElementById('mybutton');
sendButton.addEventListener('click', () => {
const inputValue = inputElement.value;
const myurl = php_data.ajax_url;
console.log(myurl);
fetch(myurl, {
method: 'POST',
credentials: 'same-origin',
body: JSON.stringify({
action: 'get_data',
_ajax_nonce: php_data.nonce,
data: inputValue,
})
})
});