function makeCall(btn) { let makePost = new XMLHttpRequest(); postData = { "button": btn }; makePost.onreadystatechange = function () { if (makePost.readyState === 4) { document.getElementById("content").innerHTML = makePost.response; } } makePost.open("POST", window.location.href, true); makePost.send(JSON.stringify(postData)); }