Przekazywanie niestandardowych nagłówków do żądania Ajax w Select2
Staramy się zaimplementować ładowanie danych Ajax Remote w Select2: -
$scope.configPartSelect2 = {
minimumInputLength: 3,
ajax: {
url: "/api/Part",
// beforeSend: function (xhr) { xhr.setRequestHeader('Authorization-Token', http.defaults.headers.common['Authorization-Token']); },
// headers: {'Authorization-Token': http.defaults.headers.common['Authorization-Token']},
data: function (term, page) {
return {isStockable: true};
},
results: function (data, page) {
// parse the results into the format expected by Select2.
// since we are using custom formatting functions we do not need to alter remote JSON data
return { results: data };
}
}
};
Używamy AngularJS. Z każdym ustawionym przez nas żądaniem HTTP domyślnie mamy nasze Authtoken jako nagłówek. Ale jakoś nie działa w połączeniu z żądaniem Ajax Select2. W powyższym kodzie skomentowany kod to moje nieudane próby.