Hi - i’ve been looking through the docs; I don’t see what I’m doing wrong here? It just goes error function and frankly I’m too new to this to understand what the error is telling me … thanks in advance!
<script type="text/javascript">
AJS.toInit(function ($) {
jQuery("#jirabutton").click(function () {
jQuery.ajax({
url: contextPath + "/rest/api/2/issue",
type: "POST",
dataType: "json",
data: {
fields:
{
project:
{
key: "LAUR"
},
summary: "REST ye merry gentlemen.",
description: "Creating of an issue using project keys and issue type names using the REST API",
issuetype: {
"name": "Story"
}
}
},
error: function (jqXHR, textStatus, errorThrown) {
alert('An error occurred... Look at the console (F12 or Ctrl+Shift+I, Console tab) for more information!');
$('#result').html('<p>status code: ' + jqXHR.status + '</p><p>errorThrown: ' + errorThrown + '</p><p>jqXHR.responseText:</p><div>' + jqXHR.responseText + '</div>');
console.log('jqXHR:');
console.log(jqXHR);
console.log('textStatus:');
console.log(textStatus);
console.log('errorThrown:');
console.log(errorThrown);
},
/**
* A function to be called if the request succeeds.
*/
success: function (data, textStatus, jqXHR) {
$('#result').html(data);
alert('Load was performed. Look at the console (F12 or Ctrl+Shift+I, Console tab) for more information! ');
console.log('jqXHR:');
console.log(jqXHR);
console.log('textStatus:');
console.log(textStatus);
console.log('data:');
console.log(data);
}
});
});
});
</script>
<button type="button" id="jirabutton">
Add to jira
</button>