jQuery(document).ready不能在IIS7下运行 [英] jQuery(document).ready doesn't run under IIS7

查看:197
本文介绍了jQuery(document).ready不能在IIS7下运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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:

<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(文档).ready函数。不用说,我的实际应用程序要复杂得多。这消除了除IIS7部署之外的所有嫌疑人。



有什么想法/建议吗?

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?

推荐答案

这可能是由src引起的引用

It's probably caused by the src reference to

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

将其替换为:

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

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

If your site is deployed in a virtual directory this is probably the case.

这篇关于jQuery(document).ready不能在IIS7下运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆