【问题标题】:Refused to execute script from 'URL' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled拒绝从 'URL' 执行脚本,因为它的 MIME 类型 ('text/html') 不可执行,并且启用了严格的 MIME 类型检查
【发布时间】:2015-07-25 23:08:28
【问题描述】:

我收到错误消息“拒绝从 'URL' 执行脚本,因为它的 MIME 类型 ('text/html') 不可执行,并且启用了严格的 MIME 类型检查。”

我的代码如下。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $.ajax({
                url: "https://www.google.com/finance/converter?a=1&from=INR&to=USD&jsoncallback=?",
                type: "GET",
                contentType: "application/javascript",                   
                cache: false,
                dataType: "jsonp",
                success : function(response){
                        alert("Hi");
                }
            });            
    });

    </script>
</head>
<body>
</body>
</html>

【问题讨论】:

  • 这个错误信息说明了一切。这是服务器端的问题。 mime 类型在响应标头中发送。如果您不是该 API 的所有者,您将无能为力。

标签: javascript jquery html ajax


【解决方案1】:

您提供的 URL (https://www.google.com/finance/converter?a=1&amp;from=INR&amp;to=USD&amp;jsoncallback=?) 似乎指向一个 HTML 页面。该错误非常不言自明。我听说谷歌货币转换器不再在线。请尝试其他一些 API,可能类似于 JsonRates

【讨论】:

    猜你喜欢
    • 2017-10-02
    • 2018-09-30
    • 2018-09-20
    • 2018-04-17
    • 2020-08-27
    • 2020-01-30
    • 2017-12-17
    • 1970-01-01
    • 2021-06-15
    相关资源
    最近更新 更多