Javascript 如何在ajax中使用multiselect过滤器

Javascript 如何在ajax中使用multiselect过滤器,javascript,php,jquery,html,ajax,Javascript,Php,Jquery,Html,Ajax,大家好,我从这个源代码下载了所有正在工作的multiselect filter,我正在尝试将其与Ajax结合使用,尽管我的Ajax功能正在工作,并在window.alert(html)中显示php生成的html,但multiselect fileter没有效果,我真的不知道如何解决它。这就是我到目前为止所做的 HTML <table> <tr> <td> <select id='pr_select' name='prj' onChange=

大家好,我从这个源代码下载了所有正在工作的multiselect filter,我正在尝试将其与Ajax结合使用,尽管我的Ajax功能正在工作,并在
window.alert(html)
中显示php生成的html,但multiselect fileter没有效果,我真的不知道如何解决它。这就是我到目前为止所做的

HTML

 <table>
  <tr>
  <td>
  <select id='pr_select' name='prj' onChange='show("pr_select","output1");' >
      <option value='28'>28</option>
      <option value='29'>29</option>
      <option value='30'>30</option>
  </select>
  </td>
  </tr>
  <tr>
  <td>
  <div id='output1'></div></td>
  </tr>
  </table>
我甚至尝试了
output1
division也像这样没有运气

 $(document).ready(function(){
     $("#output1").multiselect();
  });

尽量不要在doc ready上绑定该方法,而是在ajax的
complete
方法中应用:

<script>

  function show(sel,id) {

    var selected = $("#"+sel).val();  
    $("#"+id).html( "" );

    if (selected.length > 0 ) { 

     $.ajax({
        .......
            success: function(html) { 
                // Ajax is success but multiselect is not working.....   
                window.alert(html),
                $("#"+id).html( html );

            },
            complete:function(){
                   $("#test").multiselect(); // add it here in the ajax
            }

        });
    } 

  }
  </script>

功能显示(sel,id){
所选变量=$(“#”+sel).val();
$(“#”+id).html(“”);
如果(selected.length>0){
$.ajax({
.......
成功:函数(html){
//Ajax是成功的,但multiselect不起作用。。。。。
window.alert(html),
$(“#”+id).html(html);
},
完成:函数(){
$(“#test”).multiselect();//将其添加到ajax中
}
});
} 
}

这将解决您的问题,请尝试

success: function(html){    
        document.getElementById(id).innerHTML = html;
        $("#"+id).multiselect().multiselect('refresh').multiselectfilter();
      },
<script>

  function show(sel,id) {

    var selected = $("#"+sel).val();  
    $("#"+id).html( "" );

    if (selected.length > 0 ) { 

     $.ajax({
        .......
            success: function(html) { 
                // Ajax is success but multiselect is not working.....   
                window.alert(html),
                $("#"+id).html( html );

            },
            complete:function(){
                   $("#test").multiselect(); // add it here in the ajax
            }

        });
    } 

  }
  </script>
success: function(html){    
        document.getElementById(id).innerHTML = html;
        $("#"+id).multiselect().multiselect('refresh').multiselectfilter();
      },