jQuery(document).ready doesn't run under IIS7
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 deplo开发者_JAVA技巧yment.
Any thoughts/suggestions?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.
精彩评论