2013-03-11 126 views
5

为什么此链接不起作用?jquery.min.js加载资源失败

//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> 

错误例如: enter image description here

+0

开始是您的html页面坐在一个框架?它位于HTTP或HTTPs端口上吗?如果它在一个框架上,它不会让你加载跨域脚本。 – 2013-03-11 16:01:48

+0

@FedericoGiust您可以从不同的来源加载脚本。这就是为什么我们有JSONP。 – Antony 2013-03-11 16:03:25

回答

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

开始你没有包含HTTP://

每当你从服务器下载直接再使用http://

8

变化

<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 //?

2

链接必须http://

0

请将脚本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"> 

SCRIPT SRC应该http://

相关问题