【问题标题】:jquery.min.js Failed to load resourcejquery.min.js 加载资源失败
【发布时间】:2013-02-26 21:27:45
【问题描述】:

为什么这个链接不起作用?

//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js

<!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>
    <meta name="Description" content=" [wstaw tu opis strony] ">
    <meta name="Keywords" content=" [wstaw tu slowa kluczowe] ">
    <meta name="Author" content=" [dane autora] ">
    <title>[tytuł strony] </title>
    <link rel="stylesheet" href="style.css" type="text/css">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".animat_kon").click(function () {
                $(".animat_text").slideToggle("slow");
            });
        });
    </script>
</head>

错误示例:

【问题讨论】:

  • 您的 html 页面是否位于框架上?它位于 HTTP 或 HTTPS 端口上吗?如果它在一个框架上,它不会让你加载跨域脚本。
  • @FedericoGiust 您可以从不同的来源加载脚本。这就是我们使用 JSONP 的原因。

标签: javascript debugging


【解决方案1】:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

你没有包含 http://

当您直接从服务器下载时,请使用http://

【讨论】:

    【解决方案2】:

    改变

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    

    进入

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    

    您错过了http:。您可以跳过http:,让您的浏览器自动在 HTTPS 和 HTTP 之间进行选择。但在你的情况下,调试工具似乎不理解这种语法。

    在此处查找更多信息:Can I change all my http:// links to just //?

    【讨论】:

      【解决方案3】:

      链接必须以http://开头

      【讨论】:

        【解决方案4】:

        请将您的脚本 src 更改为:

            <link rel="stylesheet" href="style.css" type="text/css"> 
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
        <script type="text/javascript">
        

        脚本 src 应该以 http://

        开头

        【讨论】:

          猜你喜欢
          • 2021-04-30
          • 1970-01-01
          • 2012-07-24
          • 2018-01-15
          • 2019-05-28
          • 2016-06-24
          • 2016-07-01
          • 2011-06-21
          • 1970-01-01
          相关资源
          最近更新 更多