|
|
@ -2,19 +2,17 @@ function Edit(clas) { |
|
|
|
let obj = document.getElementsByClassName(clas); |
|
|
|
let data = new FormData(); |
|
|
|
if (obj[2].querySelector('input').value == 'edit') { |
|
|
|
obj[1].innerHTML = '<input type="text" style="width: 80%;" value="' + obj[1].textContent + '">'; |
|
|
|
obj[1].innerHTML = '<input type="text" style="width: 100px;" value="' + obj[1].textContent + '">'; |
|
|
|
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'; |
|
|
|
} |
|
|
@ -23,4 +21,4 @@ function Edit(clas) { |
|
|
|
xhr.responseType = 'json'; |
|
|
|
xhr.send(data); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|