.autocomplete is not a function Error

后端 未结 15 2244
抹茶落季
抹茶落季 2020-11-27 18:19

below is my My Code




        
相关标签:
15条回答
  • 2020-11-27 19:07

    Sounds like autocomplete is being called before the library that defines it is actually loaded - if that makes sense?

    If your script is inline, rather than referenced, move it to the bottom of the page. Or (my preferred option) place the script in an external .js file and then reference it:

    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script src="yourNewJSFile"></script>
    

    Edit: if you externalise your script, ensure it is referenced AFTER any JQuery libraries it relies on :)

    0 讨论(0)
  • 2020-11-27 19:10

    when you see this problem always put your autocomplete function in keyup function and ensure you have added the libraries

    $( "#searcharea" ).keyup(function(){
       $( "#searcharea" ).autocomplete({
          source: "suggestions.php"
       });
    });
    
    0 讨论(0)
  • 2020-11-27 19:12

    <head>
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
    </head>

    0 讨论(0)
提交回复
热议问题