This question already has an answer here:
- XMLHttpRequest cannot load XXX No 'Access-Control-Allow-Origin' header 6 answers
i'm doing this request in ajax but i still have this following error about CORS: XMLHttpRequest cannot load https://cubber.zendesk.com/api/v2/organizations/37520251/users.json. Request header field Access-Control-Allow-Origin is not allowed by Access-Control-Allow-Headers in preflight response. Can you help me pls ( i have seen many topic and i still don't understand why it is not working
function afficheorga(a){
$.ajax({
url: "https://cubber.zendesk.com/api/v2/users/"+a+"/organizations.json",
type: 'GET',
dataType: 'json',
cors: true ,
contentType:'application/json',
secure: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa(""));
},
success: function (data){
console.log(data.organizations[0].name);
var organisation = data.organizations[0].name;
$("#company").text(organisation);
}
})
}