3

I've been trying to access any script in my ASP.NET (Web Forms) application but it doesn't work. I'm able to access the file through the server therefore the destination is fine but the file doesnt seem to be loaded locally.

<script type="text/javascript" src="fullcalendar.js"></script>

I've tried changing the access path and it doesn't change anything. Though, it works just fine if i use the CDN :

<script src='https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/2.4.0/fullcalendar.js'></script>

I've had this issue before as I have never been able to access any JQuery or Bootstrap locally hosted scripts. Though, I'm right now facing an issue as I need to modify a line in the .js file and can't do it with the CDN. Any ideas ?

2
  • Where is the fullcalendar.js script saved in your project? What folder? Commented Oct 21, 2015 at 12:36
  • it was previously in a script folder but since it wasn't working it's now on the root of the projet as the same level as the the page that is trying to access it. Commented Oct 21, 2015 at 12:50

1 Answer 1

2

The script is trying to be called from the same directory as the ASPX page. If it's not in the same directory, then it will not load. When you load it from a CDN you have the full path and there's no 404 error.

If you use Chrome's dev tools (F12) or FireBug in Firefox then you should be able to see if it's a 404 error causing the problem.

You need to make it relative to the page or start from the root of the site.

If the script fullcalendar.js is in the root directory and the page is being called from http://somedomain.com/apath/here.aspx then it will fail.

To start from the root of your site, use:

<script type="text/javascript" src="/fullcalendar.js"></script>

If it's in the root folder, or

<script type="text/javascript" src="/script/fullcalendar.js"></script>

If it's in the scripts folder of your ASP.NET project.

If you just need to "go up" a level you can use (the .. is to go up a folder)

<script type="text/javascript" src="../fullcalendar.js"></script>
Sign up to request clarification or add additional context in comments.

4 Comments

Wow, I had tried the use the / before when it was in a folder and it didn't access it, but on the root as /fullcalendar.js it has worked, thank you!
So if you wanted to keep it in the scripts folder, you'd use <script type="text/javascript" src="/scripts/fullcalendar.js"></script> as the first / starts from the root directory
yeah but that didn't work so i'll just keep it in the root for now.
Make sure you do a CTRL + F5 to refresh, so it doesn't use a cached page when changing bit like this!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.