To simplify this test case, I created a new default .NET MVC project in Visual Studio 2010, and added the following code to the HTML header in Site.Master:
为了简化这个测试用例,我在Visual Studio 2010中创建了一个新的默认.NET MVC项目,并将下面的代码添加到网站的HTML标题中。
<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>
This works as expected in the .NET development server. However, when deployed to IIS7, the jQuery(document).ready function is not executed. Needless to say, my actual application is much more complicated. This eliminates all "suspects" except IIS7 deployment.
Any thoughts/suggestions?
这在. net开发服务器中是可以实现的。然而,当部署到IIS7时,jQuery(文档)。准备函数没有执行。不用说,我的实际应用程序要复杂得多。这消除了除IIS7部署外的所有“疑点”。任何想法/建议吗?
1 个解决方案
#1
3
It's probably caused by the src reference to
它可能是由src提到的。
src="../../Scripts/jquery-1.4.1.js"
Replace it with:
换成:
src="<%=Url.Content("~/Scripts/jquery-1.4.1.js")%>"
If your site is deployed in a virtual directory this is probably the case.
如果您的站点部署在一个虚拟目录中,那么可能就是这样。
#1
3
It's probably caused by the src reference to
它可能是由src提到的。
src="../../Scripts/jquery-1.4.1.js"
Replace it with:
换成:
src="<%=Url.Content("~/Scripts/jquery-1.4.1.js")%>"
If your site is deployed in a virtual directory this is probably the case.
如果您的站点部署在一个虚拟目录中,那么可能就是这样。