select2插件:使用input标签并采用ajax请求后台数据,搜索框无效

代码如下:

$("#countyCd").select2({
placeholder: "请选择县名称",
allowClear: true,
//minimumInputLength: 2,
ajax: {
url: getContentPath() + "xxx",
dataType: 'json',
data: function (term, page) {
return {
'searchCondition.cityCd': $('#cityCd').val()
};
},
results: function (data, page) {
return {results: data};
},
cache: true
},
formatResult: resultFormatResult, // omitted for brevity, see the source of this page
id: function (item) {
return item.adCd;
},
formatSelection: resultFormatSelection, // omitted for brevity, see the source of this page
initSelection: function (element, callback) {
var id = $(element).val();
if (id !== "") {
$.ajax(getContentPath() + "xxx?countyCd=" + id, {
dataType: "json"
}).done(function (data) {
callback(data);
});
}
}
});
无法在返回结果中使用查询框进行筛选查询图片说明