Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var url = 'http://localhost:8080/auth';
- var url2 = 'http://localhost:8080/device/7';
- var auth = {
- username: "string",
- password: "string"
- };
- //function myAuth() {
- // $.ajax({
- // url: url,
- // type: "POST",
- // data: JSON.stringify(auth),
- // crossOrigin: true,
- // withCredentials: true,
- // contentType: "application/json;"
- // }).done(function(data) {
- // console.log(data);
- // alert("OK");
- // }).fail(function(r) {
- // alert("Login Failed");
- // });
- //}
- //
- //myAuth();
- //function myAuth() {
- // $.ajax({
- // url: url,
- // crossOrigin: true,
- // xhrFields: {
- // withCredentials: true
- // },
- // beforeSend: function (xhr) {
- // xhr.setRequestHeader('Authorization', 'Basic ' + btoa('string:string'));
- // },
- // success:function(res){
- // alert("Da");
- // },
- // error:function(res){
- // alert("Net");
- // }
- // });
- //}
- //
- //myAuth();
- function dev() {
- $.ajax({
- url : url2,
- crossOrigin: true,
- method : 'GET',
- dataType: "json",
- headers: {
- 'Authorization': 'Basic ' + 'YXBpOmFwaVZJU3Rhcg==',
- 'Content-Type': 'application/json'
- },
- success:function(data){
- console.log(data);
- },
- error:function(res){
- alert("Net");
- }
- });
- }
- dev();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement