Josh Burson
Josh Burson

Reputation: 559

Jquery not working on page refresh; works otherwise

I have some jquery code on a page which does not work at all when the page is refreshed. It works when the page loads otherwise (as in from following a link or by hitting enter on the url-bar to load it).

I know that jquery isn't working at all because in console, I get this error:

Uncaught ReferenceError: $ is not defined

And I do not get it when the page loads otherwise. Despite this error, I can see that jquery.min.js was loaded in the Network tab of developer tools.

I'm at a loss as to why this could be; I've never had this issue before. Other pages of the website load jquery fine when refreshed. Any help appreciated.

Per request, a code sample, straight from the page:

$('body').hide();

does not work on page refresh. No jquery works on page refresh.

Screenshots, if they help:

https://i.sstatic.net/D8VgR.png https://i.sstatic.net/XznvS.png

Upvotes: 1

Views: 735

Answers (2)

edan291
edan291

Reputation: 162

I think the way you are commenting out parts of this script tag may have something to do with it:

<script type="text/javascript">/*head.js(
/*      '/javascript/jquery.min.js',*/
        '/javascript/scripts-min.js',
        'http://js.addthisevent.com/atemay.js'
);*/</script>

Upvotes: 0

el3ien
el3ien

Reputation: 5415

It seems like you load jQuery in your head.js function. Try this instead.

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

Upvotes: 1

Related Questions