jQuery(document).ready doesn't run under IIS7

人走茶凉 提交于 2019-12-11 02:39:52

问题


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>

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?


回答1:


It's probably caused by the src reference to

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.



来源:https://stackoverflow.com/questions/2715098/jquerydocument-ready-doesnt-run-under-iis7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!