Jump to content

jQuery not working, unless I load the library RIGHT before the script

- - - - -

  • Please log in to reply
3 replies to this topic

#1
shackrock

shackrock

    Learning Programmer

  • Members
  • PipPipPip
  • 66 posts
So, I always load jQuery in the header of my site...

Now, I'm having the problem where JS down lower in the page (body) won't end up working, unless I add the same jQuery library right before the call.

for example, I want this to run (this is located in the body):
 <script type="text/javascript">
         $(document).ready(function() {
    
[INDENT][INDENT]alert("hello");
[/INDENT][/INDENT]        });
    </script>


It will NOT run unless I paste this right about this $(document).ready( call... :
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>

However, that's ALREADY in the header - and I know it because I can view source on the page and see it twice, clearly...

What is going on here?

Thanks

#2
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
Is it returning any errors when it's not working? Can you give us more context, the code looks fine.

#3
shackrock

shackrock

    Learning Programmer

  • Members
  • PipPipPip
  • 66 posts

BlaineSch said:

Is it returning any errors when it's not working? Can you give us more context, the code looks fine.

Zero errors in firefox, a handful of CSS related warnings is all. It's literally blowing my mind... haha. There are no iframes or anything like that.

I'm not sure what type of context you'd be interested in? I'm by far no JS professional, I'm good with HTML, CSS, and PHP...

Thanks,
Scott

#4
shackrock

shackrock

    Learning Programmer

  • Members
  • PipPipPip
  • 66 posts
Arg, ok I think I found it... maybe. I have some old old JS calls in here, if I delete them, the problem goes away. They were earlier in the page as a document.ready call, and when those got caught up - I guess it didn't continue down the page.

It's really odd though, because I don't see any errors in firefox, which I usually would.

Thanks for helping me debug though, I suppose, ha!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users