最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - TypeError: $(…).autocomplete is not a function - Stack Overflow

matteradmin3PV0评论

I am getting the above error using the following code inside a ASP.NET MVC

<script type="text/javascript" >
$(document).ready(function () {
    $("#Name").autoplete({
        source: function (request, response) {
            $.ajax({
                url: "/Home/Index",
                type: "POST",
                dataType: "json",
                data: { Prefix: request.term },
                success: function (data) {
                    response($.map(data, function (item) {
                        return { label: item.Name, value: item.Name };
                    })
                }
            })
        },
        messages: {
            noResults: "", results: ""
        }
    });
})

Jquery is definitely loaded, and I have tried using a different variable for $ - any ideas what else might be the problem?

I am getting the above error using the following code inside a ASP.NET MVC

<script type="text/javascript" >
$(document).ready(function () {
    $("#Name").autoplete({
        source: function (request, response) {
            $.ajax({
                url: "/Home/Index",
                type: "POST",
                dataType: "json",
                data: { Prefix: request.term },
                success: function (data) {
                    response($.map(data, function (item) {
                        return { label: item.Name, value: item.Name };
                    })
                }
            })
        },
        messages: {
            noResults: "", results: ""
        }
    });
})

Jquery is definitely loaded, and I have tried using a different variable for $ - any ideas what else might be the problem?

Share Improve this question edited Jun 9, 2016 at 10:41 user3559349 asked Jun 9, 2016 at 9:51 Hassan AbbasHassan Abbas 4672 gold badges8 silver badges28 bronze badges 9
  • include jquery-ui also. – Kartikeya Khosla Commented Jun 9, 2016 at 9:51
  • Also added in layout page <script src="//code.jquery./jquery-1.10.2.js"></script> <script src="//code.jquery./ui/1.11.4/jquery-ui.js"></script> – Hassan Abbas Commented Jun 9, 2016 at 9:52
  • Download these files and reference them for local path. – Mairaj Ahmad Commented Jun 9, 2016 at 9:54
  • @KartikeyaKhosla Please Send me jquery-ui cdn link – Hassan Abbas Commented Jun 9, 2016 at 9:54
  • @HassanAbbas might be ordering of js, make sure to load the required libraries before your custom js. Can you show how you added the js files? – Anonymous Duck Commented Jun 9, 2016 at 9:56
 |  Show 4 more ments

1 Answer 1

Reset to default 7

When you run the application on local and including libraries from server you need to write http:// or https:// before the link as when you upload the site on server its not necessary but its required on local

<script src="http://code.jquery./jquery-1.10.2.js"></script>
<script src="http://code.jquery./ui/1.11.4/jquery-ui.js"></script>

Or else download them or use from local path.

Post a comment

comment list (0)

  1. No comments so far