Extract data from AJAX requests
Quite often you need to make custom AJAX calls, extract data from them, and potentially validate the response. With Trudon you can use a custom function to achieve this. Check the following example that retrieves the project object for a given projectId.
function trudonJSStep(element, callbacks, builtinVars, customVars)
{
// variables definition
var projectId = customVars.projectId;
var req = new XMLHttpRequest();
req.addEventListener("load", function () {
customVars.projectBody = this.responseText;
callbacks.pass("Successful response");
callbacks.done();
});
req.addEventListener("error", function (error) {
callbacks.fail(error);
callbacks.done();
})
req.open("GET", "https://jira.com/api/v2/projects/" + projectId);
req.send();
}