Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery未通过$.post评估函数_Jquery_Ajax_Jquery Select2 - Fatal编程技术网

jQuery未通过$.post评估函数

jQuery未通过$.post评估函数,jquery,ajax,jquery-select2,Jquery,Ajax,Jquery Select2,我正在使用数据类型html通过$.post在“.content”中加载html。加载的内容具有select 2 jquery插件。当我第一次加载页面时,它工作正常,Select2插件会被执行,但如果我返回并再次加载,则会出现错误 TypeError: $(...).select2 is not a function 我加载ajax的代码是 (".body .content").on("click", ".process_record", function(e){ var url

我正在使用数据类型html通过$.post在“.content”中加载html。加载的内容具有select 2 jquery插件。当我第一次加载页面时,它工作正常,Select2插件会被执行,但如果我返回并再次加载,则会出现错误

TypeError: $(...).select2 is not a function
我加载ajax的代码是

(".body .content").on("click", ".process_record", function(e){
        var url = $(this).attr("data-url");
        $.post(url, function(data){
            $(".body .content").html(data);
        },"html");
    })
我通过$.post加载的内容

<script type='text/javascript' src='js/plugins/jquery/jquery-1.9.1.min.js'></script>
<script type='text/javascript' src='js/plugins/bootstrap/bootstrap.min.js'></script>
<script type='text/javascript' src="js/plugins/select/select2.min.js"></script>
<script type="text/javascript">
    $(".select").select2();
</script> 

$(“.select”).select2();
一些html。。。。及

<select name="bank_id" class="select" style="width: 100%;" tabindex="1">
  <option value="0">Select...</option>
  <option value="1">Option</option>
 </select>                            

选择。。。
选项

看起来内容是在javascript初始化后加载的。如果您将脚本放入一个准备就绪的文档中,或者将其发送到页面底部,那么它应该可以正常工作