2014-02-27 138 views
1

我編寫了任何文本,並向我顯示與文本不匹配的結果。 無論我在現場插入什麼,select2都會始終顯示所有結果。Select2顯示所有結果

$("#UserCliente").select2({ 
    minimumInputLength: 3, 
    ajax: { // instead of writing the function to execute the request we use Select2's convenient helper 
    url: "../clients/listaclients/", 
    dataType: 'json', 
    data: function (term) { 
     return { 
      term: term, // search term 
     }; 
    }, 
    results: function (data) { // 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}; 
    } 
}, 


}); 

enter image description here

這是怎麼回事?

回答

1

我找到了解決方案。 很簡單:我的json總是返回所有結果。我在php中進行了更改以搜索term並帶來結果。 感謝