- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
问题:
最近,我一直在修改项目中的 Javascript 引用,因为它们在多个 View (_Layout 和 View 之间)中重复,从而导致错误。
目前,在本地工作时没有可见的错误,但一旦项目联机(通过 Azure),脚本部分就会出现错误 404:无法加载资源。
信息:
这是项目的当前_布局:
<!DOCTYPE html>
<html>
<head>
<meta content="text/html" charset="utf-8" http-equiv="content-type" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - Plataforma Fantasy Park</title>
<environment names="Development">
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
<script src="~/js/jquery.dataTables.min.js" asp-append-version="true"></script>
<script src="~/js/dataTables.bootstrap.min.js" asp-append-version="true"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
<link rel="stylesheet" href="~/css/bootstrap-lumen.css" />
<link rel="stylesheet" href="~/css/site.css" />
<link rel="stylesheet" href="~/css/nestednavbar.css" />
<link rel="stylesheet" href="~/css/dataTables.bootstrap.min.css" />
</environment>
<environment names="Staging,Production">
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.2.1.min.js"
asp-fallback-src="~js/jquery-3.2.1.js"
asp-fallback-test="window.jQuery"
crossorigin="anonymous"
integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk">
</script>
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
crossorigin="anonymous"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
</script>
<script src="~/js/site.min.js" asp-append-version="true"></script>
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
asp-fallback-href="/css/bootstrap-sand.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
</environment>
@RenderSection("css", required: false)
</head>
<body>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© 2017 - Plataforma Fantasy Park</p>
</footer>
</div>
@RenderSection("Scripts", required: false)
</body>
</html>
可以看出,Development
和 Staging,Production
环境都有 jquery 的引用,但为了这个项目的目的,我将只使用开发
环境的引用。
但是,在在线版本中会出现此错误:
我遇到了这些错误,通常是因为 jQuery 在 View 中定义了多次,或者在声明了 bootstrap 之类的依赖项之后,但情况似乎并非如此。作为一个后果,所有 jQuery 脚本都无法在在线版本上正确执行。
这是“网络”选项卡的结果:
看起来 jquery 库已正确加载。
以下代码是 View 的源代码:
<!DOCTYPE html>
<html>
<head>
<meta content="text/html" charset="utf-8" http-equiv="content-type" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Index - Plataforma Fantasy Park</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="/lib/bootstrap/dist/js/bootstrap.js"></script>
<script src="/js/jquery.dataTables.min.js?v=qcV1wr-bn4NoBtxYqghmy1WIBvxeoe8vQlCowLG-cng"></script>
<script src="/js/dataTables.bootstrap.min.js?v=X_58s5WblGMAw9SpDtqnV8dLRNCawsyGwNqnZD0Je_s"></script>
<script src="/js/site.js?v=ViqmmChOp_51fH3dM_KEQAFClKU0vp0UrxlREwyHKHc"></script>
<link rel="stylesheet" href="/css/bootstrap-lumen.css" />
<link rel="stylesheet" href="/css/site.css" />
<link rel="stylesheet" href="/css/nestednavbar.css" />
<link rel="stylesheet" href="/css/dataTables.bootstrap.min.css" />
</head>
<body>
<div class="container body-content">
<nav class="navbar navbar-inverse navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Menu</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Plataforma Fantasy Park</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="/HechosLiquidadors/IndexAdmin">Liquidaciones</a></li>
<li>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">Máquinas <span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a href="#" class="dropdown-item" tabindex="-1">Registro</a>
<ul class="dropdown-menu">
<li class="dropdown-item"><a tabindex="-1" href="/Machines">Datos Comerciales</a></li>
<li class="dropdown-item"><a tabindex="-1" href="/Machines/Workshop">Datos de Fabricación</a></li>
</ul>
</li>
<li class="divider"></li>
<li><a href="/Machines/Familias">Familias y Tipos</a></li>
<li class="dropdown-submenu">
<a href="#" class="dropdown-item" tabindex="-1">Gestión</a>
<ul class="dropdown-menu">
<li class="dropdown-item"><a tabindex="-1" href="/Machines/Management">Máquinas</a></li>
<li class="dropdown-item"><a tabindex="-1" href="/Machines/Contadores">Contadores</a></li>
</ul>
</li>
</ul>
</li>
<li>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">Tiendas <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="/Stores">Registro</a></li>
<li class="divider"></li>
<li><a href="/Stores/Management">Liquidadores</a></li>
</ul>
</li>
<li>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">Proveedores <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="/Suppliers/Supplier">Fabricantes y Marcas</a></li>
<li><a href="/Suppliers/Dealer">Dealers</a></li>
</ul>
</li>
<li><a href="/">Gastos</a></li>
<li>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">Usuarios <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="/User">Usuarios</a></li>
<li><a href="/ApplicationRole">Roles</a></li>
</ul>
</li>
<li><a href="/Home/About">About</a></li>
</ul>
<form method="post" id="logoutForm" class="navbar-right" action="/Account/SignOff">
<ul class="nav navbar-nav navbar-right">
<li>
<a title="Manage" href="/Manage">Hello adelgado!</a>
</li>
<li>
<button type="submit" class="btn btn-link navbar-btn navbar-link">Log off</button>
</li>
</ul>
<input name="__RequestVerificationToken" type="hidden" value="CfDJ8P12Ot7bDOBImhnZFhlI8qHJtKdMI-7lr8LhbUsd_y-3eQSYnYA19_MyhKx_JGsHcwdpm_ZQCqHibSVsLLwXaJ-PRiZg6VJXvFUtHaAK6IAPSBfOgrVrEBeimgbOvB60ahTqLMUeuUsFEXIIrmYiyBgxQVeQJEkPBbIEsMlFv-8A91-ULjKZlim2P0NZaUuLSA" /></form>
</div>
</div>
</nav>
<h2>Tiendas</h2>
<div class="btn-group" id="modalbutton">
<a id="createEditStoreModal" data-toggle="modal" data-target="#modal-action-store" class="btn btn-primary" href="/Stores/Create">
<i class="glyphicon glyphicon-plus"></i> Nueva Tienda
</a>
</div>
<p></p>
<table id="stores" class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th>
Tienda
</th>
<th>
Dirección
</th>
<th>
Área
</th>
<th>
Distrito
</th>
<th>
Cadena
</th>
<th>Editar</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div aria-hidden="true" aria-labelledby="modal-action-store-label" role="dialog" tabindex="-1" id="modal-action-store" class="modal fade">
<div class="modal-dialog ">
<div class="modal-content">
</div>
</div>
</div>
<hr />
<footer>
<p>© 2017 - Plataforma Fantasy Park</p>
</footer>
</div>
<script src="/js/store-index.js?v=xMseET7-q434oUXfBjpd5QKjSw8t0R0P_mGdZorHwB0"></script>
<script type="text/javascript">
var global = this;
var wasclicked = 0;
$(document).ready(function () {
document.getElementById("modalbutton").onclick = function () {
global.wasclicked = 1;
};
$('#modal-action-store').on('hidden.bs.modal', function () {
global.wasclicked = 0;
});
$('#modal-action-store').on('shown.bs.modal', function () {
if (global.wasclicked == 1) {
var items = "<option value='0'>-- Seleccione Distrito --</option>";
$('#DistrictID').html(items);
}
$('#DepartmentID').change(function () {
var url = '/' + "Stores/GetDistrict";
var ddlsource = "#DepartmentID";
$.getJSON(url, { DepartmentID: $(ddlsource).val() }, function (data) {
var items = '';
$("#DistrictID").empty();
$.each(data, function (i, district) {
items += "<option value='" + district.value + "'>" + district.text + "</option>";
});
$('#DistrictID').html(items);
});
});
});
});
</script>
</body>
</html>
我一直在尝试检测在线版本可能存在的问题,以产生一些在本地测试项目时未显示的错误,但我尚未成功地尝试找出答案。希望任何人都可以帮助我理解这种情况下可能出现的问题。
更新:
对于我的测试,jQuery 似乎工作了几秒钟,然后突然停止工作,但没有显示与此相关的错误消息。
请注意,错误消息也出现在 html 的顶部:
但这可能与缺少这些文件有关:
最佳答案
为什么不直接使用 bool 变量?
而不是
var global = this;
var wasclicked = 0;
像这样的东西:
var isClicked = false;
$(document).ready(function () {
$("#modalbutton").on("click", function () {
isClicked = true;
});
$('#modal-action-store').on('hidden.bs.modal', function () {
isClicked = false;
});
$('#modal-action-store').on('shown.bs.modal', function () {
if (isClicked) {
var items = "<option value='0'>-- Seleccione Distrito --</option>";
$('#DistrictID').html(items);
}
$('#DepartmentID').change(function () {
var url = '/' + "Stores/GetDistrict";
var ddlsource = "#DepartmentID";
$.getJSON(url, { DepartmentID: $(ddlsource).val() }, function (data) {
var items = '';
$("#DistrictID").empty();
$.each(data, function (i, district) {
items += "<option value='" + district.value + "'>" + district.text + "</option>";
});
$('#DistrictID').html(items);
});
});
});
});
关于jquery - ASP.NET核心: jQuery Error 404 for the online version of the project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47605329/
我正在使用JQuery Mobile,有两个可用版本:稳定版和旧版。我不熟悉后者。 什么是旧版?或与稳定版有什么区别? 建议在生产现场中使用哪一个? 非常感谢 最佳答案 旧版本是一个旧的稳定版本,由于
Lotus Notes 具有“版本控制”功能。您可以将其设置为在用户需要单击 File->New->Version 以创建新版本的模式下工作。我想在表单上的按钮中使用该功能。 有没有办法(使用 Lot
关闭。这个问题是opinion-based 。目前不接受答案。 已关闭10 年前。 已锁定。这个问题及其答案是locked因为这个问题是题外话,但却具有历史意义。目前不接受新的答案或互动。 是否有任何
我对使用数据库和数据库设计/创建模式非常陌生,我非常感谢一些建议/建议。我正在创建一个应用程序,用户在其中输入数据,并向用户提供该数据的版本控制。用户可以进入并恢复更改或更新值(有点像 git)等,我
尝试启动带头 Selenium session 时出现此错误。 我使用的命令是driver = webdriver.Chrome(executable_path=r'C:\Users\Administ
Apple 的文档本来可以更清楚地说明如何提交更新版本。 正如标题所问,有什么区别 itunes connect 中的版本号(提交更新时必须提供) xcode 中的捆绑版本 捆绑版本字符串,短 它们有
当我在我的 Android 设备上运行我的应用程序时出现错误: meteor run android-device --settings settings.json --mobile-server=m
v = data.getValues(XP_PHONE); for (int i = 0; i alter 'table_foo', {NAME => 'column_fam_foo', V
我在Google CoLab中有这样一个错误:。以下是我的Cuda和Torch版本:。CUDA版本:。这是pytorch版本:2.0.1+cu118我试图安装Cuda 11.8,但没有成功。
我从其他用户那里发现了“类似”的问题,但没有一个答案有效。我正在尝试安装这些软件包: if (!require("BiocManager")) install.packages("BiocMana
我正在使用 Version Maven Plugin插件 use-latest-versions将 groupID=com.example* 内部依赖版本更新到最新版本的功能。这是使用 Jenkins
我是 Kotlin 应用程序开发的初学者。当我尝试构建应用程序时发生以下错误 - e: C:/Users/Lenovo/.gradle/caches/transforms-2/files-2.1/32
我正在尝试安装一个名为 metaBIT 的程序。我能够将它添加到我的路径中。但是当我执行时: metaBIT -h 它出错并给我这个: Traceback (most recent call last
在使用选项 -smt2 -in 启动 Z3 后,我可以获取 Z3 的版本吗?有点像 (get-z3-version) ; Z3 4.3.2 x64 // Desired reply 最佳答案 在SM
这个问题在这里已经有了答案: What is the difference between Version and 'Runtime Version' in .Net? (1 个回答) 关闭 9 年
new Version(AssemblyFileVersionAttribute.Version) 总是会成功吗? 这是我的代码。 Contract.Ensures(Contract.Result()
我正在尝试针对另一个使用 libcurl 共享库的共享库 (libtheirstuff.so) 交叉编译我自己的共享库 (libmystuff.so),但出现以下错误: libmystuff.so:
在 Bazaar 中,如果您在 foo.html 中有冲突,它将生成额外的 3 个文件 foo.html.BASE foo.html.OTHER foo.html.THIS 那么你可以 diff -N
我的 java 7 和 java 8 都安装在我的 Windows 系统的 C:\Program Files\Java 下 在环境的路径中我像这样指定了java 7的路径。 %JAVA_HOME%/b
#version 330 和 #version 330 core 有什么区别? 核心重要吗? 最佳答案 这两个版本声明是等价的。 核心 是默认值。来自 GLSL 3.30 规范: If no prof
我是一名优秀的程序员,十分优秀!