get a request on html button click code example
Example 1: using post from any button
$('.btn-logout').on('click', function() {
$('<form action="<?=$url_local?>member/logout" method="post"> <input name="token" value="<?= $obj_user ? $obj_user['token'] : '' ?>"/> </form>').appendTo('body').submit();
});
Example 2: send get request with button to endpoint
form.addEventListener('submit', (event) => {
event.preventDefault();
let input = document.querySelector('input');
let method = 'GET';
let endpoint = `request url ${input.value}`;
xhr.open(method, endpoint);
xhr.send();
});