当实现自动完成时,我在控制台日志上收到问题脚本?

问题描述 投票:0回答:1

我从事 asp.net mvc 工作。我在运行自动完成时遇到问题,但我不知道如何解决它

运行 ASP.NET MVC 应用程序时,这些问题会显示在辞职页面的 console.log 上。

辞职页面继承布局页面

_LayoutResignation
.

辞职页面显示错误如下:

jquery-1.5.min.js:16 Uncaught Type Error: Cannot read properties of undefined (reading 'length')
    at Function.each (jquery-1.5.min.js:16:10613)
    at t.widget (jquery-ui.min.js:6:4729)
    at jquery-ui.min.js:7:13824
    at jquery-ui.min.js:6:73
    at jquery-ui.min.js:6:84
bootstrap.js:15 Uncaught Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4
    at bootstrap.js:15:11
    at bootstrap.js:17:2
datatables.min.js:176 Uncaught TypeError: l(...).on is not a function
    at datatables.min.js:176:457
    at datatables.min.js:60:299
    at datatables.min.js:60:326
jquery.validate.unobtrusive.js:156 Uncaught TypeError: $form.off is not a function
    at Object.attachValidation (jquery.validate.unobtrusive.js:156:26)
    at HTMLFormElement.<anonymous> (jquery.validate.unobtrusive.js:249:26)
    at Function.each (jquery-1.5.min.js:16:10828)
    at init.each (jquery-1.5.min.js:16:7403)
    at Object.parse (jquery.validate.unobtrusive.js:246:20)
    at HTMLDocument.<anonymous> (jquery.validate.unobtrusive.js:428:28)
    at Object.resolveWith (jquery-1.5.min.js:16:12509)
    at Function.ready (jquery-1.5.min.js:16:8628)
    at HTMLDocument.A (jquery-1.5.min.js:16:14342)
RequesterIndex?filenumber=103085:351 Uncaught ReferenceError: searchText is not defined
    at HTMLInputElement.<anonymous> (RequesterIndex?filenumber=103085:351:41)
    at HTMLInputElement.handle (jquery-1.5.min.js:16:28630)
    at HTMLInputElement.l (jquery-1.5.min.js:16:25280)

我的布局页面是主页

_LayoutResignation.cshtml

<html>
<head>
    <title>@ViewBag.Title - Resignation Submission Form</title>
    <link href="~/Content/DataTables/datatables.min.css" rel="stylesheet" />
    <link href="~/Content/animate.min.css" rel="stylesheet" />
    @Styles.Render("~/Content/css")

    @Scripts.Render("~/bundles/modernizr")


    @Scripts.Render("~/bundles/jquery")

</head>
<body>
    
    <div class="container body-content">
        @RenderBody()
     
    </div>

    @Scripts.Render("~/bundles/bootstrap")
    @RenderSection("scripts", required: false)

    <script src="~/Scripts/DataTables/datatables.min.js"></script>
    
</body>
</html>

在辞职页面上我实现了自动完成。

控制台日志的所有问题都显示在辞职页面控制台日志上

    @model HR.WorkforceRequisition.Models.ResignationRequester
    
    
    @{
        Layout = "~/Views/Shared/_LayoutResignation.cshtml";
    }
<form id="ResignationApp" >
</form>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js" type="text/javascript"
        language="javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.5.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js" type="text/javascript"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"></script> 
$(document).ready(function () {
            $("#txtLineManagerId").autocomplete({
                source: function (request, response) {
                    var searchText = $("#txtLineManagerId").val();
                    $.ajax({
                        url: '@Url.Action("GetAllEmployeeBasedSearchText", "Resignation")',
                        data: { searchText: searchText },
                        method: "GET",
                        dataType: "json",
                        success: function (data) {
                            response($.map(data, function (item) {
                                return { label: item.EmployeeID, value: item.EmployeeID, employeeName: item.EmployeeName };
    
                            }))
    
                        }
                    });
                },
                select: function (event, ui) {
                    $("#LineManagerName").val(ui.item.employeeName);
         
                },
                minLength: 4,
            });
           });

那么如何解决上面与 jQuery 和 bootstrap 相关的问题?

注意我的应用程序上运行的 jQuery 版本是 3.4.1 .

javascript jquery asp.net-mvc jquery-ui datatables
1个回答
0
投票

错误消息中:

Uncaught Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4

查看错误消息的第一行,看来您的jQuery版本是1.5(不是像您所说的3.4.1):

jquery-1.5.min.js:16 Uncaught Type Error: Cannot read properties...

© www.soinside.com 2019 - 2024. All rights reserved.