function Edit(clas) { let obj = document.getElementsByClassName(clas); let data = new FormData(); if (obj[2].querySelector('input').value == 'edit') { obj[1].innerHTML = ''; obj[2].querySelector('input').value = 'ok'; } else { let value = {}; value.login = obj[0].textContent; value.pwd = obj[1].querySelector('input').value; console.log(value); let xhr = new XMLHttpRequest(); data.append('value', JSON.stringify(value)); xhr.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this.response); obj[1].innerHTML = this.response[1]; obj[2].querySelector('input').value = 'edit'; } }; xhr.open('POST', 'cible/admin.php', true); xhr.responseType = 'json'; xhr.send(data); } }