【发布时间】:2015-12-16 05:19:52
【问题描述】:
我已经编写了一个代码来使用 select2 和 ajax 显示相关的 serch 结果。结果正确显示在控制台中,但未显示在 select2 的结果表中。它只是说明没有找到结果...下面是我的代码:
<script type="text/javascript">
$(".showname").select2({
ajax: {
url:"http://hub.w.net/datatables/brand_processing",
//dataType: "json",
//delay: 250,
type:'POST',
data: function (params) {
return {
search_name: params.term // search term
//console.log(params:params);
};
},
processResults: function (data) {
// parse the results into the format expected by Select2.
// since we are using custom formatting functions we do not need to
// alter the remote JSON data
console.log(data.data);
return {
data:{text:data.data,id:data.id}
};
},
cache: true
},
minimumInputLength: 1
});
</script>
有什么建议吗?
【问题讨论】:
-
你在控制台得到了什么?
标签: ajax jquery-select2