<form name="person">
<input type="text" placeholder="username" id="login-name" name="name">
<input type="password" placeholder="password" id="login-pass" name="password">
<input type="button" id="formsub" value="Вход">
</form>
let myButton = document.getElementById('formsub');
myButton.addEventListener('click',function () {
let data = new FormData(document.forms.person);
let xhr = new XMLHttpRequest();
xhr.open('POST', 'http://localhost:3000/add', false);
xhr.send(data);
let body=JSON.parse(xhr.response);
console.log(body);
let us = document.createElement('h2');
us.innerHTML = body["name"];
let mydiv = document.getElementById('tester');
mydiv.appendChild(us);
})
let multer = require('multer');
let upload = multer();
app.post('/add',upload.fields([]),function (req,res) {
console.log(req.body);
res.json(req.body);
});
<form action="http://localhost:3000/add" method="post" id="myform">
<input type="text" placeholder="username" id="login-name" name="name">
<input type="password" placeholder="password" id="login-pass" name="password">
<button id="formsub">ВХОД</button>
</form>
<div id="tester"></div>
<script>
let myButton = document.getElementById('formsub');
myButton.addEventListener('click',function () {
let form = document.querySelector('form');
let data = new FormData(form);
let xhr = new XMLHttpRequest();
xhr.open('POST', 'http://localhost:3000/add', false);
xhr.send(data);
})
</script>
<a href="javascript:void(0)" class="btn2">Подробнее</a></span>
let info = document.getElementsByClassName('btn2');
for(let j=0;j<info.length;j++){
info[j].addEventListener("click", function(){
let inf = this.parentElement.parentElement;
about(inf);
});}
function about(info) {
let url = '/about';
let a = info.querySelector('p').textContent;
url += "?param="+a;
let xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.send();
}