Advertisement
fahmihilmansyah

js 1

Jun 22nd, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dibawah ini javascript ajax, nah saya ingin mengubahnya menggunakan jquery, tp kenapa response http 415 terus ya:
  2. function loadDoc() {
  3.   var user = document.getElementById('name').value;
  4.   var password = document.getElementById('password').value;
  5.   var xhttp = new XMLHttpRequest();
  6.   xhttp.onreadystatechange = function() {
  7.     if (xhttp.readyState == 4 && xhttp.status == 200) {
  8.       document.getElementById("demo").innerHTML = xhttp.responseText;
  9.     }
  10.   };
  11.   xhttp.open("POST", "http://localhost:8080/SecurityApi/system/login", true);
  12.   xhttp.send(btoa(user + ":" + password));
  13. }
  14.  
  15. ======================================================
  16.  
  17. var dats = btoa($("#name").val() + ":" + $("#password").val() );
  18.     $.ajax({
  19.       url:"http://localhost:8080/SecurityApi/system/login",
  20.       type:"POST",
  21.       data:btoa($("#name").val() + ":" + $("#password").val() ),
  22.       contentType:"application/json; charset=utf-8",
  23.       dataType:"json",
  24.       success: function(msg){ alert(msg) }
  25.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement