We are trying to implement Ajax Remote data loading in 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 };
}
}
};
We are using AngularJS.
With each Http request we have set it's default to have our Authtoken as header.
But somehow it is not working in conjunction with Select2 Ajax request. In above code, commented code are my failed attempts.