Uncaught referenceerror $ is not defined Error Resolution

Asked 2 years ago, Updated 2 years ago, 40 views

$("#search") when the code is executed.

on the autocomplete line

'uncaught referenceerror $ is not defined' An error occurs.

I understand that the reason for the error is that the jquery has not been loaded, but I wonder what the problem is.

 <script type="text/javascript">
                        (function () {
                            window.item_list = {{item_list|safe}};
                        })();
                        $("#search").autocomplete({
                            source: window.item_list
                        });
                    </script> 

This is a jquery upload source referring to http://jqueryui.com/autocomplete/.

<!-- autocomplete from jQuery Ui -->
    <script src='{% static "js/jquery-1.11.3.min.js" %}'></script>
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

Below is the path to jquery-1.11.3.min.js.

jquery javascript

2022-09-22 11:52

2 Answers

js/plugins/jquery-1.11.3.min.js

I think it's missing

And if you're going to use 1.11.3 version, take out 1.12.4 version of CDN..


2022-09-22 11:52

Of course the codes are in this order, right?

<body>

    Code blah blah...


<script src='{% static "js/jquery-1.11.3.min.js" %}'></script>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type="text/javascript">
    (function () {
        window.item_list = {{item_list|safe}};
    })();
    $("#search").autocomplete({
        source: window.item_list
    });
</script> 
</body>
</html>


2022-09-22 11:52

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.