Files
2024_WEBSITE_fipf/plugins/fipfcard_plugin/js/menu/example_menu.js
asus 0177531924 - forget old ajax wp, now use fetch wp
- trying js files without imports
2024-02-26 13:18:19 +01:00

26 lines
625 B
JavaScript

const inputElement = document.getElementById('mytext');
const sendButton = document.getElementById('mybutton');
sendButton.addEventListener('click', () => {
let inputValue = inputElement.value;
inputValue = {
key1: 'value1',
key2: 'value2'
};
inputValue = JSON.stringify(inputValue);
console.log("inputValue:");
console.log(inputValue);
PLGNTLS_ajax('get_data', inputValue)
//PLGNTLS_fetch('get_data', {body: {inputValue}})
.then((response) => response.json())
.then((data) => {
console.log("dataaa: ");
console.log(data);
})
.catch((error) => {
console.log("error: ");
console.log(error);
});
});