2014-11-24 92 views
3

我環顧了類似上面的問題,並沒有一個幫助。

這裏是我的腳本

<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> 
    <script type="text/javascript" src="network.json"></script> 
    <script type='text/javascript' src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"> </script> 
    <link type="text/css" href="http://code.jquery.com/ui/1.9.1/themes/smoothness/jquery-ui.css" rel="stylesheet" /> 

<body>  
     <link href="ajs_network1.css" rel="stylesheet" type="text/css" /> 
     <script src="ajs_network1.js" type="text/javascript"></script> 

    </body> 

下面是函數試圖調用JQuery的

$(function() { 
    $("#search").autocomplete({ 
     source: optArray 
    }); 
}); 

出於某種原因,它造就了錯誤

TypeError: $(...).autocomplete is not a function. 

我猜測香港專業教育學院完成腳本有問題嗎?

+3

您需要添加的jQuery UI庫'<鏈接相對= 「樣式的」 href =「// ajax.googleapis.com/ajax/libs/ jqueryui/1.11.2/themes/smoothness/jquery-ui.css「/> \t ' – Satpal 2014-11-24 12:43:35

+1

在頭標頂部加載jquery – 2014-11-24 12:44:15

+1

與Satpal同意autocomplete是jQueryUI的插件,因此在jQuery lib之後包含此庫。 – Jai 2014-11-24 12:45:39

回答

-1

的聯繫是正確的我使用。但是,因爲我在網上檢索鏈接,所以我沒有在開始時輸入http。所以鏈接現在是:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>   
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" /> 
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>‌​ 

出於某種原因此外,還有被隱藏字符,當我複製這樣的鏈接wasnt工作的鏈接。在使用此功能時,請確保您的瀏覽器正在檢索鏈接。 FireBug幫助我。點擊「網絡」,它會告訴你瀏覽器正在導入哪些腳本。

三江源所有幫助:)

2

嘗試增加這些鏈接到你的代碼,你缺少這些

<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" /> 
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script> 
5

by just adding this link reference my issue was resolved

<script async src="//code.jquery.com/ui/1.10.1/jquery-ui.min.js"></script>