reset_pwd.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const btnLoginPage = document.querySelector('.btn-login');
  2. const btnUserProfile = document.querySelector('.btn-userProfile');
  3. const btnLogout = document.querySelector('.btn-logout');
  4. function loginControl() {
  5. btnLoginPage.style.display = 'none';
  6. btnLogout.style.display = 'block';
  7. btnUserProfile.style.display = 'block';
  8. }
  9. loginControl();
  10. function renderXHR_data(jsonObj) {
  11. XHRstring = ''
  12. for (const [key, value] of Object.entries(jsonObj)) {
  13. console.log(value)
  14. if (typeof (value) == "object") {
  15. XHRstring += (key+'=['+value.join(',')+']&')
  16. }
  17. else {
  18. XHRstring += (key + '=' + value + '&')
  19. }
  20. }
  21. XHRstring = XHRstring.substring(0, XHRstring.length - 1);
  22. return XHRstring
  23. }
  24. $(".sender").click(function () {
  25. var pwd = $("#in_pwd").val();
  26. var code = $("#code").val();
  27. var url = "/reset_pwd";
  28. var xhr = new XMLHttpRequest();
  29. xhr.open("POST", url);
  30. xhr.setRequestHeader("accept", "application/json");
  31. xhr.setRequestHeader("Content-Type", "application/json");
  32. xhr.onreadystatechange = function () {
  33. if (xhr.readyState === 4) {
  34. alert('重設成功')
  35. }};
  36. var data = `{"code":"`+ code+`","password":"`+pwd+`"}`
  37. xhr.send(data);
  38. });