I am using this code:-
var saveData=$.ajax({
url: "api",
headers: {
"Access-Control-Allow-Origin":"*",
"Access-Control-Request-Headers": "x-requested-with",
"Access-Control-Allow-Methods": "GET, POST, PATCH, PUT,DELETE,OPTIONS",
"Access-Control-Allow-Headers": "Origin, Content-Type, X-Auth-Token",
"Accept":"application/json"
},
type: 'POST',
dataType: 'application/octet-stream',
contentType: 'image/jpeg',
processData: false,
data: binaryData,
success: function (data) {
alert(data);
},
error: function(){
alert("Cannot get data");
}
});
But I am getting this:- Access to XMLHttpRequest at 'api/bintest1.jpeg' from origin 'null' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.