wip found how to theorically get ajax request in php but for the moment i get error 400
This commit is contained in:
18
plugins/wp_model_plugin/js/menu/menu.js
Normal file
18
plugins/wp_model_plugin/js/menu/menu.js
Normal 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,
|
||||
})
|
||||
})
|
||||
});
|
||||
Reference in New Issue
Block a user