12345678910111213141516171819202122232425262728293031323334353637383940 |
- $("#btn_login").click(function () {
- var url = "login";
- var xhr = new XMLHttpRequest();
- xhr.open("POST", url);
- console.log('url:');
- console.log(url);
- xhr.setRequestHeader("accept", "application/json");
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.onreadystatechange = function () {
- if (xhr.readyState === 4) {
- console.log(xhr.status);
- responseOBJ = JSON.parse(xhr.responseText) ; // error
- console.log(responseOBJ.access_token);
- // document.cookie = 'jwt_token='+responseOBJ.jwt_token // access_token -> jwt_token
- document.cookie = 'jwt_token='+responseOBJ.access_token;
- console.log('cookie: ');
- console.log(document.cookie); // test log
- console.log('登入成功');
- alert('登入成功!!');
- window.location.replace("/home");
- }
- };
- var data = "grant_type=&username=" + $('#username').val() + "&password="+$('#password').val()+"&scope=&client_id=&client_secret=";
- console.log("data:");
- console.log(data); // test
- xhr.send(data);
- });
-
- // $( ".side-bar-link" ).click(function() {
- // console.log(1);
- // alert('hi');
- // $(this).addClass("active");
- // $(".active").siblings().removeClass('active');
- // });
-
-
|