हम Select2 में अजाक्स रिमोट डेटा लोड हो रहा है लागू करने के लिए कोशिश कर रहे हैं Ajax अनुरोध करने के लिए कस्टम हेडर पासिंग: -पर 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 };
}
}
};
हम AngularJS का उपयोग कर रहे हैं। प्रत्येक एचटीपी अनुरोध के साथ हमने अपने ऑथोकोकन को हेडर के रूप में डिफॉल्ट सेट कर दिया है। लेकिन किसी भी तरह यह चयन 2 अजाक्स अनुरोध के साथ संयोजन में काम नहीं कर रहा है। उपरोक्त कोड में, टिप्पणी कोड मेरे असफल प्रयास हैं।
स्वीकार किए जाते हैं जवाब 2012 में ही एकमात्र विकल्प हो सकता है, लेकिन आज [इस उत्तर] (http://stackoverflow.com/a/28793936/ 971557) सभी के लिए काम करना चाहिए। –