If everything you are using to construct the headers is synchronous, you can just pass a beforeSend
function in your ajax options. i.e.:
prefetch: {
url: "http://localhost/api-1.1/search/country/key/%QUERY",
filter: function(response) {
return response.countries;
},
ajax: {
beforeSend: function(jqXHR, settings) {
var authHeaders;
// pull apart jqXHR, set authHeaders to what it should be
jqXHR.setRequestHeader('Authorization', authHeaders);
}
}
}
just so there is no confusion, you are setting auth headers to gain access to the APIs, the APIs define Access-Control-Allow-Origin