2016-12-07 10 views
1

私はいくつかの助けが必要です。私はAJAX経由でURLを呼び出すと、ユーザーがフォームにデータを入力するとオートコンプリートの結果を取得するJQueryオートコンプリートスクリプトを作成しようとしています。しかし、私はここでjavascript、jQuery、Ajax Autocomplete

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

を得続ける私のコードは、私は、誰かが私を助けることを望んミリアンペア

$(document).ready(function() { 
 

 
$(document).ready(function() { 
 
    var test = ["Roanoke", "Salem", "Alexandria", "Buena Vista", "Bedford", "Bristol", 
 
     "Charlottesville", "Chesapeake", "Clifton Forge"]; 
 
    
 
    $("#city").autocomplete({ 
 
     source: test 
 
    }); 
 
    
 
    $("#city").autocomplete({ 
 
     source: "city.php" 
 
    }); 
 
    
 
});
<!DOCTYPE html> 
 

 
<html> 
 
    <head> 
 
     <title>TODO supply a title</title> 
 
     <meta charset="UTF-8"> 
 
     <link rel="stylesheet" href="css/Style.css"> 
 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 
     <script src="//code.jquery.com/jquery-1.11.2.min.js"></script> 
 
     <script src="script/jscript.js"></script> 
 
    </head> 
 
    <body id = "body"> 
 
     <section><label id = "adr">Address:</label> 
 
        <label id = "add"><input type="text" name="address" id="address" placeholder="enter address"></label> 
 
        <br> 
 
        <input type="text" name="city" id="city" placeholder="enter city"> 
 
        <label id = "st"><input type="text" name="state" id="state" placeholder="enter state"></label> 
 
        <label id = "zi"><input type="text" name="zip" id="zip" placeholder="enter zip code"></label> 
 
       </form> 
 

 
      </div> 
 
     </section> 
 

 
    </body> 
 
</html>

です。

答えて

2

オートコンプリートはjQueryUIの一部であり、jQueryではありません。オートコンプリートについては、https://jqueryui.com/autocomplete/をご覧ください。そのウェブサイトには、jquery UIをダウンロードするためのリンクもあります。

あなたはjQueryの2つの異なるバージョンが含まれていますがありませんjQueryのUI

+0

ましたが私にそれを上向きいただきありがとうございます – Jabateh