1

I have the following file organization:

Project > SubFolder1> SubFolder2> Subfolder3> Test.aspx

and I am trying to include Jquery library from

Project> Scripts

in test page I did both:

<script src="~/Scripts/jquery-1.9.1.js"></script>

and

<script src="../../../Scripts/jquery-1.9.1.js"></script>

but it gives me that the resource cannot be found and the URI in source view is:

localhost:44388/Project/SubFolder1/SubFolder2/SubFolder3/~/Scripts/jquery-1.9.1.js

How can I include the library correctly?

wala rawashdeh
  • 423
  • 5
  • 17

4 Answers4

3

Try this (without tilde):

<script src="/Scripts/jquery-1.9.1.js"></script>

Or if you are in an ASP.NET MVC context:

<script src="@Url.Content("~/Scripts/jquery-1.9.1.js")"></script>
philipproplesch
  • 2,127
  • 17
  • 20
0

I would suggest keeping all the javascript files in a seperate folder in the ROOT folder and name it 'js'.

For ex if your root folder is PROJECTS, then make a new folder 'js' and paste all you javascript and jquery files in this folder then you can reference this files in this manner

<script src="js/jquery-1.9.1.js"></script>
AnaMaria
  • 3,520
  • 3
  • 19
  • 36
0

I have to include it like this

<script src="/Project Name/Scripts/jquery-1.9.1.js"></script>
wala rawashdeh
  • 423
  • 5
  • 17
0

You could use a CDN for these kind of universally known, general purpose libraries.

A Content Delivery network gives you the advantage of faster load time, because of the clients will be served by the nearest/fastest server (less network latency), and of course, if the client already visited some other website which also made use of jQuery over the CDN, there's a big chance the file is already in the browsers cache, so no download of the file is actually needed.

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>

See http://jquery.com/download/

Adrian Salazar
  • 5,279
  • 34
  • 51