2014-12-31 23 views
0

我是繼汽車在YouTube phpacademy建議視頻系列,但就死在這一點上,似乎無法找到什麼文錯誤:PHP自動提示教程錯誤

這裏是我的形式:

<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> 
       <script src="scripts/typeahead.js"></script> 
       <script src="scripts/searchScript.js"></script> 
       <form action="index.php" method="GET"> 
       <input type="text" name="user" id="header-query"><input type="submit" name="submit" value="Go"> 
       </form> 

這裏是我的searchScript.js

$(function(){ 

var users = new Bloodhound({ 
    datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), 
    queryTokenizer: Bloodhound.tokenizers.whitepsace, 
    remote: 'inc/search.inc.php?query=%QUERY' 
}); 

users.initialize(); 

$('#header-query').typeahead({ 
    hint: true, 
    highlight: true, 
    minlength: 3 
}, { 
    name: 'user', 
    displaykey: 'name', 
    source: users.ttAdapter() 
}); 

}); 

我得到我的Firefox控制檯上出現以下錯誤:

Error: datumTokenizer and queryTokenizer are both required 


...,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFuncti... 

On Jquery.min.js(line2, col 1820) 
+1

只是指出了這一點。如果在'jquery.min.js'上有錯誤,這意味着你的代碼與語法不同。並且因爲它說'兩者都是必需的' –

+0

@MAgeshKumaar我知道,但它在哪裏?這是我找不到的。 –

回答

3

嘗試以下操作:

看來你拼錯了js文件包含

目前,它是:

<script src="scripts/typahead.js"></script> 

應該

<script src="scripts/typeahead.js"></script> 

爲了進一步解決問題,而是包括typeahead.bundle.js腳本。我想你可能會缺少bloodhound.js代碼:

<script type='text/javascript' src="http://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.js"></script> 
+0

我收到此錯誤:錯誤:datumTokenizer和queryTokenizer都需要 \t ...,「」),isReady:!0,錯誤:函數(a){拋出新錯誤(a)},noop:函數(){},isFuncti ... \t jquery.min.js(line 2,col 1820) –