Based on answers of the this and this questions, i wrote the following code to GET:
var setHeader = function (xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa($rootScope.login.Gebruikersnaam + ":" + $rootScope.login.Wachtwoord));
}
$rootScope.getCollection = function () {
return new(Backbone.Collection.extend({
url : $rootScope.login.Serverlocatie + '/Table?Active=true&SL=ID'
}));
}
$rootScope.getCollection().fetch({
beforeSend : setHeader
}).then(function (a) {
console.log(a);
});
Normally, it should do a GET operation with the specified request header. However, i take the following as response:
Request Method:OPTIONS
Status Code:400 Not a REST method:
So, OPTIONS method is not allowed and if i do just a GET operation (using ajax), it is working well.
The question is: how can i make GET call instead of OPTIONS in this case?