从 jQuery 成功调用 AJAX 时检索 glyphicons-halflings-regular.woff2 时出错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29258276/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error retrieving glyphicons-halflings-regular.woff2 on successful AJAX call from jQuery
提问by Johan Gunawan
I get an error message saying that jQuery couldn't find the path to the glyphicons-halflings-regular.woff2. The error shows up when the function for successful AJAX request is ran. In that function I inserted a hyperlink that uses a glyphicon from Twitter Bootstrap.
我收到一条错误消息,说 jQuery 找不到 glyphicons-halflings-regular.woff2 的路径。运行成功的 AJAX 请求函数时会显示错误。在该函数中,我插入了一个使用 Twitter Bootstrap 中的字形的超链接。
Looking at the path, I am sure that it is the correct path so I don't know why it's giving me the error. How could I fix this error?
查看路径,我确定它是正确的路径,所以我不知道为什么它会给我错误。我该如何解决这个错误?
回答by cederlof
Using IIS I fixed it inside the Web.config-file, add the following inside <system.webServer>
:
使用 IIS 我在 Web.config 文件中修复它,在里面添加以下内容<system.webServer>
:
<staticContent>
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
</staticContent>
Notice I remove the extensions first, in case they already exist.
请注意,我首先删除扩展名,以防它们已经存在。
回答by palehorse
To get it to work with IIS Express you need to add the mime type. In a text editor open the file in your Documents folder at %UserProfile%\Documents\IISExpress\config\applicationhost.config
要使其与 IIS Express 一起使用,您需要添加 mime 类型。在文本编辑器中打开 Documents 文件夹中的文件,地址为%UserProfile%\Documents\IISExpress\config\applicationhost.config
Search for a line that looks like this:
搜索如下所示的行:
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
I would recommend changing it as the official MIME type has changed, but regardless simply copy that line and add a new one and change the fileExtension to .woff2 in the new one. Here is my modified file (with the corrected MIME types)
我建议更改它,因为官方 MIME 类型已更改,但无论如何只需复制该行并添加一个新行,然后在新行中将 fileExtension 更改为 .woff2。这是我修改后的文件(带有更正的 MIME 类型)
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
回答by eMpTy43
If you prefer to work in the IIS GUI or aren't comfortable with command line or config files, follow the steps below.
如果您更喜欢在 IIS GUI 中工作或不习惯命令行或配置文件,请按照以下步骤操作。
To resolve the error retrieving glyphicons-halflings-regular.woff2in IIS, you just need to add a MIME type for woff2.
要解决在 IIS 中检索 glyphicons-halflings-regular.woff2的错误,您只需为woff2添加一个 MIME 类型。
- OpenIIS and Selectyour server
- In the Features View, select MIME Types
- Click Add...in the Actionspane (top-right corner)
- Enter the File name extensionof .woff2
- Enter the MIME typeof application/font-woff
- 打开IIS 并选择您的服务器
- 在功能视图中,选择MIME 类型
- 单击“操作”窗格(右上角)中的“添加...”
- 输入文件扩展名的.woff2
- 输入MIME类型的应用/字体WOFF
Also, as palehorsenoted, ensure the MIME type for both .woffand .woff2are application/font-woff
此外,如palehorse指出的,确保的MIME类型都.woff和.woff2是应用/字体WOFF
Sources:
资料来源: