Guest User

Untitled

a guest
Aug 24th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. var loginData = {
  2. grant_type: 'password',
  3. username: parmUsername,
  4. password: parmPassword
  5. };
  6.  
  7. $.ajax({
  8. beforeSend: function (xhrObj) {
  9. xhrObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
  10. },
  11. type: 'POST',
  12. url: 'http://202.189.20.8:8081/api/v1/Token',
  13. dataType:'json',
  14. data: loginData
  15. })
  16. .done(function (response, textStatus, jqXHR) {
  17. window.location.replace('views/mainpage.html');
  18. })
  19. .fail(function (jqXHR, textStatus, errorThrown) {
  20. console.log(errorThrown);
  21. })
  22.  
  23. var formBody = [];
  24. for (var property in loginData) {
  25. var encodedKey = encodeURIComponent(property);
  26. var encodedValue = encodeURIComponent(loginData[property]);
  27. formBody.push(encodedKey + "=" + encodedValue);
  28. }
  29. formBody = formBody.join("&");
Add Comment
Please, Sign In to add comment