2013-03-11 183 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://

相關問題