【发布时间】:2017-01-26 10:40:00
【问题描述】:
我对这段代码中的 Select2 组件有疑问:
$("#group_select_name").select2({
placeholder: "Select a Group",
allowClear: true,
ajax: {
type: "GET",
url: "../contactGroup",
contentType: "application/json; charset=utf-8",
dataType: 'json',
processResults: function(data) {
return {
results: $.map(data, function(obj) {
console.log("update 2")
return {
id: (obj.id),
text: (obj.name)
};
})
};
},
}
});
一切正常,但是当我尝试使用搜索字段搜索某些内容时,该组件会向服务器发出多个不需要的 AJAX 请求。在浏览器的控制台中,我看到了数千个“更新 2”。
Select 的版本是4.0.3。有什么建议吗?
【问题讨论】:
标签: jquery ajax jquery-select2 jquery-select2-4