3
本地主機上的Chrome on Rails。下面是頁面的修剪版本:JQuery插件使用給出「未定義」錯誤
<!DOCTYPE html>
<head>
<link href='http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css' rel='stylesheet'>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js' type='text/javascript'></script>
<script src='http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.js' type='text/javascript'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.3.1/jquery.cookie.min.js' type='text/javascript'></script>
<meta content="authenticity_token" name="csrf-param" />
<meta content="blahblah=" name="csrf-token" />
<link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/application.js?body=1" type="text/javascript"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0 maximum-scale=1.0">
</head>
<body data-action='index' data-controller='application'>
</body>
在Chrome控制檯(以及在腳本中越往下),$.cookie
是不確定的,$.cookie("a", "b")
拋出一個錯誤。
我試了幾個其他CDN,但同樣的問題。
編輯: 我想在Chrome的Javascript控制檯,這(我認爲)頁面加載後運行的東西了。我可以檢查「資源」選項卡,並看到插件已被加載沒有問題。如果我重新排列以在Jquery之前鏈接插件,我會收到預期的錯誤。
確保你做到這一點的JavaScript加載後(文件準備好):http://jsfiddle.net/cq9m8/ – pickypg 2013-05-02 02:42:23
您是否使用'HTTP://localhost'或'file:// localhost'?由於您的網址沒有「http:」前綴,因此它們會繼承用於包含網頁的協議。 – Barmar 2013-05-02 02:45:29
提供包含$ .cookie的代碼段/塊 – 2013-05-02 02:45:53