Using Bootstrap 3 and Bootstrap-Select plugin I am trying to load the options of the select drop down by ajax from database.the code works perfectly when I remove the select picker
lass from the select
element but with that class (which is required to use bootstrap select) it is not loading any of options.
使用Bootstrap 3和Bootstrap-Select插件我试图从数据库加载ajax选择下拉列表的选项。当我从select元素中移除选择选择器lass但是使用该类时,代码工作正常(需要使用bootstrap select)它没有加载任何选项。
<select id="arearesults" class="selectpicker" data-live-search="true">
<option value="select">Select From The List</option>
</select>
$('.btn-group .btn').click(function(){
$.post(
'con/animalList.php',
{ selType : this.id },
function(data)
{
$('#arearesults').html(data);
}
);
});
I already test the bootstrap select plugin and it is also working in stand alone mode (hard coded). can you please let me know why this is happening and how I can solve this issue?
我已经测试了bootstrap select插件,它也在独立模式下工作(硬编码)。你可以告诉我为什么会这样,以及如何解决这个问题?
Thanks
谢谢
2 个解决方案
#1
7
Multiple errors in your code.
代码中存在多个错误。
-
You haven't mentioned the response
data-type
in the$.post
. Is the response data"JSON"
or"html"
, etc?您还没有在$ .post中提到响应数据类型。响应数据是“JSON”还是“html”等?
-
After filling the values through AJAX in the selectbox you have to refresh it. Code:
在选择框中通过AJAX填充值后,您必须刷新它。码:
$('#arearesults').selectpicker("refresh");
#2
2
this solution worked for me
这个解决方案对我有用
$('.selectpicker').selectpicker({});
#1
7
Multiple errors in your code.
代码中存在多个错误。
-
You haven't mentioned the response
data-type
in the$.post
. Is the response data"JSON"
or"html"
, etc?您还没有在$ .post中提到响应数据类型。响应数据是“JSON”还是“html”等?
-
After filling the values through AJAX in the selectbox you have to refresh it. Code:
在选择框中通过AJAX填充值后,您必须刷新它。码:
$('#arearesults').selectpicker("refresh");
#2
2
this solution worked for me
这个解决方案对我有用
$('.selectpicker').selectpicker({});