Search code examples
javascriptjqueryasp.net-mvcautocompletejquery-ui-autocomplete

Javascript files conflict when autocomplete search on ASP.NET MVC


I have two javascript file on my project.if I close one of these files, the other works. But they dont work together.How can I use ?

This file helps work dropdown

<script src="~/vendor/jquery/jquery.min.js"></script> 

This file helps work Autocomplete search textbox

    <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>

Autocomplete search Code:

<script>
    $(document).ready(function () {        
        $("#txtSearch").autocomplete({
            source: '/Home/Search/',
            messages: {
                noResults: 'no results',
                results: function (amount) {
                    return amount + 'results.'
                }
            }
        })
    });
</script>

Solution

  • just use these two js instead of three js,it will resolve your issue

    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>