AJAX

<!DOCTYPE html>
<html lang="en"> 
    <head> 
        <title>"Guessing game</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width">
        <script> 
function guessed() { 
    var xhr = new XMLHttpRequest();
    xhr.open('GET', 'get_test/', true);
    xhr.onreadystatechange = function () {
        if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
            console.log("Received: " + xhr.responseText);
        }
    };
    xhr.send(null);
}

function do_post() {
    var xhr = new XMLHttpRequest();
    xhr.open('POST', 'post_test/', true);
    xhr.onreadystatechange = function () {
        if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) {
            console.log("Data received: " + xhr.responseText);
        }
    };
    xhr.setRequestHeader("Content-type", "application/json");
    xhr.send(JSON.stringify({'my_number': 42}));
}
        </script> 
    </head> 

    <body> 
        <input type="button" onclick="guessed()" value="GET"> <br/>
        <input type="button" onclick="do_post()" value="POST"> <br/>
    </body> 
</html>