Advertisement
Guest User

Untitled

a guest
Sep 8th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. var user = 'user';
  2. var pass = 'pass';
  3. var myURL = 'https://project.MYDOMAIN.com:8444/rest/api/2/issue/createmeta?projectKeys=POLEX&issuetypeNames=Task&expand=projects.issuetypes.fields';
  4.  
  5. /*
  6. var jiraAPI = "";
  7. $.getJSON( jiraAPI, {
  8. format: "json"
  9. })
  10. .done(function( data ) {
  11. arr = $.map(data, function(el) { return el; })
  12. });
  13. */
  14.  
  15. function loadJSON(path, success, error) {
  16. var xhr = new XMLHttpRequest();
  17. xhr.onreadystatechange = function() {
  18. if (xhr.readyState === XMLHttpRequest.DONE) {
  19. if(xhr.status === 200) {
  20. if(success)
  21. success(JSON.parse(xhr.responseText));
  22. }
  23. else {
  24. if(error)
  25. error(xhr);
  26. }
  27. }
  28. };
  29. xhr.open('GET', path, true);
  30. xhr.setRequestHeader('Authorization', 'Basic ' + btoa(user + ":" + pass));
  31. xhr.send();
  32. }
  33.  
  34.  
  35. loadJSON(
  36. myURL,
  37. function(data) { console.log(data); },
  38. function(xhr) { console.error(xhr); }
  39. );
  40.  
  41.  
  42. $("#myDIV").click(function() {
  43. $.ajax({
  44. url: myURL,
  45. username: user,
  46. password: pass,
  47. type: 'GET',
  48. //type: 'POST',
  49. contentType: "application/json; charset=utf-8",
  50. dataType: "json",
  51. xhrFields: {
  52. withCredentials: true
  53. },
  54. beforeSend: function(xhr) {
  55. xhr.setRequestHeader('Authorization', 'Basic ' + btoa(user + ":" + pass));
  56. console.log("start");
  57. },
  58. success: function() {
  59. //arr = $.map(data, function(el) { return el; });
  60. console.log("done");
  61. },
  62. /*
  63. done: function() {
  64. //arr = $.map(data, function(el) { return el; });
  65. console.log("finish");
  66. }
  67. */
  68. });
  69. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement