script_index.js 626 B

1234567891011121314151617181920212223
  1. $("#go_login").click(function () {
  2. var url = "http://127.0.0.1:8000/login";
  3. var xhr = new XMLHttpRequest();
  4. xhr.open("POST", url);
  5. xhr.setRequestHeader("accept", "application/json");
  6. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  7. xhr.onreadystatechange = function () {
  8. if (xhr.readyState === 4) {
  9. console.log(xhr.status);
  10. console.log(xhr.responseText);
  11. alert('登入成功')
  12. window.location.replace( "/index" )
  13. }
  14. };
  15. var data = "grant_type=&username="+$('#username').val()+"&password=qwe&scope=&client_id=&client_secret=";
  16. xhr.send(data);
  17. });