【发布时间】:2018-02-12 14:38:39
【问题描述】:
尝试执行 Jquery 功能,一切似乎都设置正常,但我在浏览器控制台日志中收到此错误
SCRIPT5009: 'jQuery' 未定义 bootstrap.js (20,1)
HTML1300:发生导航。 1 (1,1) 2 CSS3121:媒体查询 -ms-viewport 已被弃用。
SCRIPT5009: SCRIPT5009: 'jQuery' 未定义 bootstrap.js (21,1)
SCRIPT5009: SCRIPT5009: '$' 未定义 SendEmail.js (1,1)
这是我的视图脚本/样式:
@model Linkofy.Models.EmailAccount
@{
ViewBag.Title = "SendMail";
}
@section Styles {
<link href="@Url.Content("~/Styles/Edit.css")" rel="stylesheet" type="text/css" />
}
@section Scripts {
<script src="@Url.Content("~/Javascript/SendEmail.js")"></script>
}
我的功能(SendEmail.js):
$("#templateName").on("change", function () {
var tempID = $(this).find('option:selected').val();
var url = "/Identifiers/TemplateData/" + tempID;
console.log()
$.ajax({
type: "GET",
dataType: "json",
contentType: "application/json",
url: url, // Variabel
showLoader: true,
success: test // Function
});
});
function test(data) {
data = $.parseJSON(data);
$('#subject').val(data.subject);
$('#body').val(data.body);
}
捆绑包:
// For more information on bundling, visit https://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at https://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));
}
}
}
如果不填充此文件上的文本就无法发布,所以这是我的整个布局文件:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - linkofy</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar" style="background-color: LightSteelBlue;">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Linkofy", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Domains", "Index", "Identifiers")</li>
<li>@Html.ActionLink("Clients", "Index", "Clients")</li>
<li>@Html.ActionLink("Links", "Index", "Links")</li>
<li>@Html.ActionLink("Status", "Index", "Status")</li>
</ul>
@Html.Partial("_LoginPartial")
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - Orb Online - Liam Cook</p>
</footer>
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
@RenderSection("Styles", required: false)
</body>
</html>
【问题讨论】:
-
你能展示你的layout.cshtml吗?
-
@DanielA.White 添加了它:)
-
显示您的浏览器控制台。
-
@UbiquitousDevelopers 你的意思是从 fn+f12 窗口吗?我把所有东西都放在了最上面,还是你的意思是别的?
-
@Lucie - 是的,fn + f12 并显示控制台
标签: c# jquery .net asp.net-mvc