I am having trouble retrieving JSON responses from an API. The error message "Cross-Origin Read Blocking (CORB) blocked cross-origin response" keeps popping up. I've tried searching online for a solution to this problem, but so far, I haven't been successful.
The API is supposed to provide a generated session.
When I check the headers, I can see that there are multiple headers attached to the request.
Interestingly, if I directly paste the URL into my web browser, I am able to get the JSON response with the values. However, when I use the URL in an ajax function, I am denied access.
jQuery.ajax({
type: 'GET',
crossOrigin: true,
url: "https://apitest.mobzgo.co.za/getSession?username=********&passingword=*****",
dataType: "jsonp",
contentType: "jsonp;",
success: function (response) {
alert(JSON.stringify(response));
},
error: function (jqXHR, exception, errorThrown) {
var msg = '';
if (jqXHR.status === 0) {
msg = 'Not connect.\n Verify Network.';
} else if (jqXHR.status === 404) {
msg = 'Requested page not found. [404]';
} else if (jqXHR.status === 500) {
msg = 'Internal Server Error [500].';
} else if (exception === 'parsererror') {
msg = errorThrown;
} else if (exception === 'timeout') {
msg = 'Time out error.';
} else if (exception === 'abort') {
msg = 'Ajax request aborted.';
} else {
msg = 'Uncaught Error.\n' + jqXHR.responseText;
}
alert(msg);
}
});