I am trying to run $.ajax() in javascript as below:
var settings = {
"url": {external_api_url},
"method": "POST",
"timeout": 0,
"headers": {
"content-type": "application/json",
"accept": "application/json",
"authorization": "Basic {key}"
},
"data": JSON.stringify({
"url": {data_response_url}
"data": {object}
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
This is throwing me the CROS origin error since i am using some external url, also tried including Access-Control-Allow-Origin: *, but didnt work.
What the accurate way to bypass this error ?