JQuery (document) .ready not working under IIS7

To simplify this test case, I created a new default 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 on a .NET development server. However, when deployed to IIS7, the jQuery (document) .ready function fails. Needless to say, my actual application is much more complex. This excludes all "suspects" except for the IIS7 deployment.

Any thoughts / suggestions?

+2


a source to share


1 answer


This is probably caused by the src reference to

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

      

Replace it:



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

      

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

+3


a source







All Articles