Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ================function menggunakan javascript ajax==========
- function loadDoc() {
- var user = document.getElementById('name').value;
- var password = document.getElementById('password').value;
- var xhttp = new XMLHttpRequest();
- xhttp.onreadystatechange = function() {
- if (xhttp.readyState == 4 && xhttp.status == 200) {
- document.getElementById("demo").innerHTML = xhttp.responseText;
- }
- };
- xhttp.open("POST", "http://123.123.123.20:8080/SecurityApi/system/login", true);
- xhttp.send(btoa(user + ":" + password));
- }
- ================function menggunakan jquery ajax =============
- var name = $("#name").val();
- var password = $("#password").val();
- var strings= JSON.stringify(btoa(name +":"+password));
- $.ajax({
- url:"http://123.123.123.20:8080/SecurityApi/system/login",
- dataType: 'json',
- type: 'post',
- contentTYpe: "application/json",
- data: strings,
- processData: false,
- success: function( data, textStatus, jQxhr ){
- alert(data);
- },
- error: function( jqXhr, textStatus, errorThrown ){
- console.log( errorThrown );
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement