jQuery(document).ready 无法在 IIS7 下运行

标签 jquery iis-7 document-ready

为了简化此测试用例,我在 Visual Studio 2010 中创建了一个新的默认 .NET MVC 项目,并将以下代码添加到 Site.Master 中的 HTML header 中:

<script type="text/javascript" src="../../Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
  jQuery(document).ready(function () { alert('jQuery document ready'); });
</script>

这在 .NET 开发服务器中按预期工作。但是,当部署到IIS7时,jQuery(document).ready函数不会被执行。不用说,我的实际应用要复杂得多。这消除了除 IIS7 部署之外的所有“嫌疑人”。

有什么想法/建议吗?

最佳答案

这可能是由 src 引用引起的

src="../../Scripts/jquery-1.4.1.js"

替换为:

src="<%=Url.Content("~/Scripts/jquery-1.4.1.js")%>"

如果您的站点部署在虚拟目录中,情况可能就是这样。

关于jQuery(document).ready 无法在 IIS7 下运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2715098/

相关文章:

delphi - 在使用 IIS7 的 Delphi CGI 上无法看到 WSDL

iis-7 - ERROR_DESTINATION_NOT_REACHABLE : Web deployment task failed

iis-7 - IIS 7中缺少Adminscripts文件夹

javascript - 如果我将 jQuery 放置在将某些 HTML 注入(inject) DOM 到 $ ('document' ).ready() 中时将被使用,这是一个问题吗?

c# - 从 WebService (.NET) 使用 C# 调用 javascript

javascript - 为什么当我打开子菜单页面时向上滚动?

javascript - 未捕获的 ReferenceError : do_login is not defined at HTMLButtonElement. onclick

javascript - Bootstrap-select 插件 : how to avoid flickering

jquery - head.ready() 与 $(document).ready

jquery - 使用 jQuery document.Ready 函数将事件附加到元素