tags:

views:

138

answers:

2

Hello, I've built an mvc application which contains some jquery code. When I run the app from my ide, everything works perfectly. When I publish to the server and open the page, the jquery does not work. I get object expected errors.

Could this be due to my file mappings? here is a sample of my mapping in the app -

<script type="text/javascript" href="../../Scripts/jquery-1.3.2.js"></script>  

I published the app to iis7 successfully, but the jquery is broken. I did publish to an application within an existing web site.

Any thoughts?

+3  A: 

You may be experiencing problems with your relative path.

You can try this, which is a path from the application root:

<script type="text/javascript" href="/Scripts/jquery-1.3.2.js"></script>  

Or this C# solution:

<script src="<%= Url.Content("~/Scripts/jquery-1.3.2.js") %>" type="text/javascript"></script>
Sohnee
Thanks. Is either one of these solutions preferred over the other, or just use whatever one works?
czuroski
second one is better :)
Jarek
Won't the second option also disable jQuery Intellisense for any JavaScript code on the page?
GWB
Well... yes, but his problem is a deployment not developement.
Jarek
A: 

the second line (c# solution) worked for me. Thanks for that!

If you use the first solution, it does not work on the server.

sajid