script_index.js 598 B

12345678910111213141516171819202122
  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. window.location.replace( "/index" )
  12. }
  13. };
  14. var data = "grant_type=&username="+$('#username').val()+"&password=qwe&scope=&client_id=&client_secret=";
  15. xhr.send(data);
  16. });