var parameters = '{"parameter": [{"name":"id", "value": "2"}, {"name":"id2", "value": "testing"}]}';
$.ajax({
url: "https://abc/job/test/buildWithParameters",
beforeSend: function(xhr) {
xhr.withCredentials = true;
xhr.setRequestHeader('cache-control', 'no-cache, must-revalidate, post-check=0, pre-check=0');
xhr.setRequestHeader("Authorization", "Basic " + btoa("abc:*******"));
},
type: "POST",
dataType: "jsonp",
contentType: "application/json; charset=utf-8",
cache: false,
async: false,
processData: false,
data: 'json='+parameters,
success: function (data) {
alert(JSON.stringify(data));
},
error: function(){
alert("Cannot get data");
}
});
Can someone please help me with what am I doing wrong? Also it always goes in the error function and not in the success, why is that the case?