将输入发送到Ajax中的文件

I want to put the code in the textarea's as below and send it to a file and I do not know Ajax I understand it but can't write.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Testing</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="main.js"></script>
</head>
<body>
    <textarea id="html"></textarea>
    <textarea id="js"></textarea>
    <textarea id="css"></textarea><br>
    <input type="button" value="Run" id="run">
    <iframe src="example.html" frameborder="0"></iframe>
    <button onclick="loadDoc()">Try The Ajax</button>
</body>
</html>

The contents of main.js are:

function loadDoc() {
    var fred = document.getElementById("js");
    var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            document.getElementById("html").innerHTML =
                this.responseText;
        }
    };
    xhttp.open("GET", "example.html", true);
    xhttp.send();
}

It loads but will not send. I have tried xhttp.send(fred, "example.html",true) but it did not work. So abit like codepen or jsfiddle

Ajax is the act of making an HTTP request from JavaScript without leaving the page.

It cannot write to files.

You can make an HTTP request to a URL which is handled by server-side code that uses information in the request to write to a file (although it is more usual to write to a database).

Pick a programming language you like and look up an introductory tutorial for server-side programming using it.