Advertisement
Guest User

Untitled

a guest
Feb 5th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var url = 'http://localhost:8080/auth';
  2. var url2 = 'http://localhost:8080/device/7';
  3. var auth = {
  4.         username: "string",
  5.         password: "string"
  6. };
  7.  
  8. //function myAuth() {
  9. //    $.ajax({
  10. //            url: url,
  11. //            type: "POST",
  12. //            data: JSON.stringify(auth),
  13. //            crossOrigin: true,
  14. //            withCredentials: true,
  15. //            contentType: "application/json;"
  16. //        }).done(function(data) {
  17. //            console.log(data);
  18. //            alert("OK");
  19. //        }).fail(function(r) {
  20. //            alert("Login Failed");
  21. //        });
  22. //}
  23. //
  24. //myAuth();
  25.  
  26.  
  27. //function myAuth() {
  28. //    $.ajax({
  29. //        url: url,
  30. //        crossOrigin: true,
  31. //        xhrFields: {
  32. //            withCredentials: true
  33. //        },
  34. //        beforeSend: function (xhr) {
  35. //            xhr.setRequestHeader('Authorization', 'Basic ' + btoa('string:string'));
  36. //        },
  37. //        success:function(res){
  38. //                    alert("Da");
  39. //                },
  40. //        error:function(res){
  41. //                    alert("Net");
  42. //                }
  43. //    });
  44. //}
  45. //
  46. //myAuth();
  47.  
  48.  
  49. function dev() {
  50.     $.ajax({
  51.         url : url2,
  52.         crossOrigin: true,
  53.         method : 'GET',
  54.         dataType: "json",
  55.         headers: {
  56.         'Authorization': 'Basic ' + 'YXBpOmFwaVZJU3Rhcg==',
  57.         'Content-Type': 'application/json'
  58.         },
  59.         success:function(data){
  60.             console.log(data);
  61.         },
  62.         error:function(res){
  63.             alert("Net");
  64.         }
  65.     });
  66. }
  67. dev();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement