Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var user = 'user';
- var pass = 'pass';
- var myURL = 'https://project.MYDOMAIN.com:8444/rest/api/2/issue/createmeta?projectKeys=POLEX&issuetypeNames=Task&expand=projects.issuetypes.fields';
- /*
- var jiraAPI = "";
- $.getJSON( jiraAPI, {
- format: "json"
- })
- .done(function( data ) {
- arr = $.map(data, function(el) { return el; })
- });
- */
- function loadJSON(path, success, error) {
- var xhr = new XMLHttpRequest();
- xhr.onreadystatechange = function() {
- if (xhr.readyState === XMLHttpRequest.DONE) {
- if(xhr.status === 200) {
- if(success)
- success(JSON.parse(xhr.responseText));
- }
- else {
- if(error)
- error(xhr);
- }
- }
- };
- xhr.open('GET', path, true);
- xhr.setRequestHeader('Authorization', 'Basic ' + btoa(user + ":" + pass));
- xhr.send();
- }
- loadJSON(
- myURL,
- function(data) { console.log(data); },
- function(xhr) { console.error(xhr); }
- );
- $("#myDIV").click(function() {
- $.ajax({
- url: myURL,
- username: user,
- password: pass,
- type: 'GET',
- //type: 'POST',
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- xhrFields: {
- withCredentials: true
- },
- beforeSend: function(xhr) {
- xhr.setRequestHeader('Authorization', 'Basic ' + btoa(user + ":" + pass));
- console.log("start");
- },
- success: function() {
- //arr = $.map(data, function(el) { return el; });
- console.log("done");
- },
- /*
- done: function() {
- //arr = $.map(data, function(el) { return el; });
- console.log("finish");
- }
- */
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement