我正在尝试在我的自定义joomla组件中使用bootstrap select2(ajax),但我不会在返回时列出我的数据。 javscript看起来如下
jQuery("#e6").select2({
placeholder: "PLZ // Bundesland // Ort angeben",
minimumInputLength: 2,
ajax: {
url: "index.php?option=com_tieraerzte&task=tieraerzt.locator&tmpl=component",
dataType: 'json',
data: function(term, page) {
return {
q: term, // search term
};
},
results: function(data, page) {
return {results: data};
}
},
formatResult: function(data) {
//shows undefined on return
alert(data.plz);
return "<div class='select2-user-result'>" + data.plz + "</div>";
},
formatSelection: function(data) {
return data.plz;
}
});
返回的json数据的snipet
[[{"plz":"10247","kiez":"Friedrichshain-Kreuzberg","ort":"Berlin","bundesland":"Berlin"}]]