Mild Fuzz
Mild Fuzz

Reputation: 30671

Why won't my JS file load?

using this code:

<script src="<?php bloginfo('template_url'); ?>/scripts/hovermenus.js" type="text/javascript"></script>

to load this script

firebug is not showing this script as loaded, however, these scripts:

<script src="<?php bloginfo('template_url'); ?>/scripts/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="<?php bloginfo('template_url'); ?>/scripts/salf_ui.js" type="text/javascript"></script>
    <script src="<?php bloginfo('template_url'); ?>/scripts/date.js" type="text/javascript"></script>
    <script src="<?php bloginfo('template_url'); ?>/scripts/datePicker.js" type="text/javascript"></script>

all load perfectly well. I have double, triple and quadruple checked the file is in the right directory.

Upvotes: 0

Views: 21480

Answers (7)

polearnik
polearnik

Reputation: 1

Had a similar problem, cant load script /js/search_ads.js It was problem in my adblock extension After renaming to search.js problem was disappearing

Upvotes: 0

Had a similar problem, shoving my head against a wall trying to figure it out. Turned out the js file had a syntax issue buried in it, something stupid that didn't show in my editor ... in this case it was a hanging 'var ' with nothing after it. As soon as I deleted that, everything was copacetic.

So my recommendation if you run into this is what I did - remove all functions and add them back one by one until you find one that kills it.

Upvotes: 0

user1786058
user1786058

Reputation:

I had the similar problem: same file would not load on other pages(master pages)

original: 

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

fixed:    
   <script type="text/javascript" src="/Scripts/scriptMob.js"></script>

only removed dots and first slash

Additionally you can check in firebug(HTML section), expand the reference line

    (+) <script src="../../Scripts/scriptMob.js" type="text/javascript"> 

to check whether browser actually reads the js file correctly.

the error message was saying: [SqlException]: Error converting data type nvarchar to int.

Upvotes: 0

Peter Ajtai
Peter Ajtai

Reputation: 57685

Looks like the problem is with your file

Make sure the file .../scripts/hovermenus.js exists. Navigate there and copy paste the file name from there.

Could the script be in another directory? could it be hoverMenus.js or hover.menus.js.... etc.

If none of this works, try copying and renaming the file. See if you can load the renamed version. If you can't, it's something in the file.

Unrelated: You should declare your variables with var so you don't create a bunch of global variables attached to window.

Upvotes: 1

Hooray Im Helping
Hooray Im Helping

Reputation: 5264

Make sure you've closed all your script tags above the one you're trying to load.

Upvotes: 0

Rocket Ronnie
Rocket Ronnie

Reputation: 1116

charset isnt a valid attribute for the script tag, try removing it

EDIT

Actually it is valid, try removing it anyway :)

Upvotes: 0

Related Questions