19 lines
432 B
JavaScript
19 lines
432 B
JavaScript
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,
|
|
})
|
|
})
|
|
});
|