Suppose, I have a text file like this:
<button onclick="logIn.newTask();">Log In</button>
Now, in Javascript I want to load it in my HTML page with a simply document.appendChild(); like this:
var client = new XMLHttpRequest();
client.open('GET', 'http://localhost/button.txt');
client.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
document.appendChild(client.responseText); // Load the button see above.
}
}
client.send();
My problem is that this code gives me this error:
So, I try to find how I can traduce text to node but I can not find anything in this subject.
Short question:
I want to load some html's elements in my web page but I can not find any way to achieve this purpose.
Any help is very appreciated.
Tell me if you have some questions or comments.

document, outside</body>.