|
@ -2,19 +2,17 @@ function Edit(clas) { |
|
|
let obj = document.getElementsByClassName(clas); |
|
|
let obj = document.getElementsByClassName(clas); |
|
|
let data = new FormData(); |
|
|
let data = new FormData(); |
|
|
if (obj[2].querySelector('input').value == 'edit') { |
|
|
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'; |
|
|
obj[2].querySelector('input').value = 'ok'; |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
let value = {}; |
|
|
let value = {}; |
|
|
value.login = obj[0].textContent; |
|
|
value.login = obj[0].textContent; |
|
|
value.pwd = obj[1].querySelector('input').value; |
|
|
value.pwd = obj[1].querySelector('input').value; |
|
|
console.log(value); |
|
|
|
|
|
let xhr = new XMLHttpRequest(); |
|
|
let xhr = new XMLHttpRequest(); |
|
|
data.append('value', JSON.stringify(value)); |
|
|
data.append('value', JSON.stringify(value)); |
|
|
xhr.onreadystatechange = function() { |
|
|
xhr.onreadystatechange = function() { |
|
|
if (this.readyState == 4 && this.status == 200) { |
|
|
if (this.readyState == 4 && this.status == 200) { |
|
|
console.log(this.response); |
|
|
|
|
|
obj[1].innerHTML = this.response[1]; |
|
|
obj[1].innerHTML = this.response[1]; |
|
|
obj[2].querySelector('input').value = 'edit'; |
|
|
obj[2].querySelector('input').value = 'edit'; |
|
|
} |
|
|
} |
|
@ -23,4 +21,4 @@ function Edit(clas) { |
|
|
xhr.responseType = 'json'; |
|
|
xhr.responseType = 'json'; |
|
|
xhr.send(data); |
|
|
xhr.send(data); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|