ajax is working
This commit is contained in:
@@ -6,13 +6,23 @@ sendButton.addEventListener('click', () => {
|
||||
const myurl = php_data.ajax_url;
|
||||
console.log(myurl);
|
||||
|
||||
const data = new FormData();
|
||||
data.append('action', 'get_data',);
|
||||
data.append('_ajax_nonce', php_data.nonce);
|
||||
data.append('data', inputValue);
|
||||
|
||||
fetch(myurl, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
body: JSON.stringify({
|
||||
action: 'get_data',
|
||||
_ajax_nonce: php_data.nonce,
|
||||
data: inputValue,
|
||||
})
|
||||
body: data
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
console.log("data: ");
|
||||
console.log(data);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log("error: ");
|
||||
console.log(error);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user