简体   繁体   English

Select2 mimetype错误

[英]Select2 mimetype error

I am trying to use Select2 and Chrome is refusing to execute the script because the mimetype is text/html. 我正在尝试使用Select2,Chrome因为它的mimetype是text / html而拒绝执行脚本。 I am using 4.0.3. 我正在使用4.0.3。 Here is my html: 这是我的html:

<link href="static/js/common/select2/css/select2.min.css" rel="stylesheet" />
<script src="static/js/common/select2/js/select2.js"></script>
<script src="static/js/controllers/common/SelectAgency.js"></script>

<select id="auto"></select>

The code for SelectAgency.js is this: SelectAgency.js的代码是这样的:

var data = [{ id: 0, text: 'enhancement' }, { id: 1, text: 'bug' }, { id: 2, text: 'duplicate' }, { id: 3, text: 'invalid' }, { id: 4, text: 'wontfix' }];

$("#auto").select2({
 placeholder:'Test'
})

The select box appears, but it does not contain anything. 将显示选择框,但其中不包含任何内容。 Also this message appears in the console 此消息也出现在控制台中

select2.min.js:233 Resource interpreted as Stylesheet but transferred with MIME type text/html: " http://localhost:8080/foiaonline/action/public/request/static/js/common/select2/js/static/js/controllers/common/select2/css/select2.min.css ". select2.min.js:233资源被解释为样式表,但以MIME类型text / html传输:“ http:// localhost:8080 / foiaonline / action / public / request / static / js / common / select2 / js / static / js /controllers/common/select2/css/select2.min.css “。

I was using an older version of select2(3.5.1). 我使用的是select2(3.5.1)的旧版本。 In 3.5.1 select2 is initialized with: 在3.5.1中,select2初始化为:

$(panel).select2({
    placeholder:placeholderStr,
    data: items
});

<input id="panel" type="text", class="auto"/></td>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM