.autocomplete is not a function Error

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

below is my My Code




        
相关标签:
15条回答
  • 2020-11-27 18:50

    You are calling the function before the page loads jQuery. It is always advisable to use jQuery inside

    $(document).ready(function(){ //Your code here });
    

    In your case:

    $(document).ready(function(){
       $(function(){
          $( "#searcharea" ).autocomplete({
             source: "suggestions.php"
          });
          $( "#searchcat" ).autocomplete({
             source: "suggestions1.php"
          });
       });
    });
    
    0 讨论(0)
  • 2020-11-27 18:51

    Check the Sources-> Scripts in browser Inspect tool. Sometimes multiple jQuery files can be referring. In ASP.NET MVC, this usually happens when the layout page already has a jQuery reference.

    0 讨论(0)
  • 2020-11-27 18:54

    Possibly multiple jquery.js file are added in , and the conflict appeared.

    0 讨论(0)
  • 2020-11-27 18:58

    I faced the same problem and try to solve, but unfortunately it wouldn't work anymore ! If you are facing the same problem and can't find the solution, it may help you.

    If you configure jquery/jquery-ui globally in webpack, you need to import autocomplete like this

    import { autocomplete } from 'webpack-jquery-ui';
    

    And you must include jquery-ui.css in the head section of html, i don't understand why its not working without it!

    <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
    

    Hope your problem will be solved.

    And make sure you include/install the following three

    1. jquery-ui-css
    2. jquery-ui
    3. jquery
    0 讨论(0)
  • 2020-11-27 18:58

    Loading jQuery library before Angularjs library helped me.

    <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)
  • 2020-11-27 18:59

    For my case, my another team member included another version of jquery.js when he add in bootstrap.min.js. After remove the extra jquery.js, the problem is solved

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