TypeError: 'undefined' is not a function (evaluating '$(document)')
I know there is one other topic with a similar issue, but trying the solutions in there didn’t resolve the problem.
I’m using WordPress 3.1.2 and I’m trying to get it to load a page, but something in WordPress or what I’m typing doesn’t seem to let it work.
<div id=test>
<b>Great scott</B>
</div>
<div id=recall>
<b>see you at the party</b>
</div>
<script src=jquery.js>
</script>
<script>
$(#test).load(search.php);
</script>
That’s the code I’m trying to use, it works on a different WP site I worked on, creating the prototype so to speak.
The problem seems to come from pointing it to the jQuery file because not even alerts work. However, when I take out the src
the alerts appear as normal.
I also used the jQuery’s tutorial on jQuery’s website to make sure the jQuery file itself was working and that the page ran the jQuery on there perfectly.
I’ve tried using JQuery()
instead of $()
, but when I tried that, search.php
still doesn’t load and there is no error produced in the error log either (I’ve been using Firefox to test it)
I also tried wrapping it in a function like similar questions have suggestion but that flags up either the same error or no error at all.
Is there a way to fix this or work around this?
You need quotes around the #test:
Undefined means the selectors hasn’t found anything.
For more about jQuery selectors, look here: http://api.jquery.com/category/selectors
When debugging – it can help to use firebug in firefox, or the developer console in chrome… and you can type in the javascript directly to see if it runs, or even something like $(‘#test’) to see what is being selected.
Load the function after the DOM is loaded: