Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've asked this question here before, but never got an answer. In Firebug, in the Console, I get 'ReferenceError: jQuery is not defined'. I have no clue why. Can anyone help?

Here is the page I'm working on: http://goinspire.com/jwrp-hotel-registration/

I can provide other code files from my site if it will help - please let me know which ones you want.

Thank you in advance!

Edit: How do I figure out why jQuery is not included in the page early enough? thank you!

share|improve this question
1  
two issues, none directly related to WordPress. You have code trying to use jQuery before jQuery is included in the page. The second issue is you have a file using jquery instead of jQuery. –  Milo Mar 6 at 19:10
    
Thanks! I fixed issue #2, but I don't know to fix #1. Would that be in one of the php template files? –  user3515 Mar 6 at 19:14

3 Answers 3

The following code is trying to use jQuery before the jQuery library is loaded. Hard to say exactly where it is coming from, but it seems related to your form. If that is a custom form, maybe check in your theme's header.php? It is definitely not being enqueued properly and so I would guess it might be hard-coded.

<script>jQuery(function(){jQuery('#input_38_7').attr('placeholder','First Name');jQuery('#input_38_6').attr('placeholder','Last Name');jQuery('#input_38_2').attr('placeholder','Email');jQuery('#input_38_3').attr('placeholder','Phone Number');});</script>

Maybe try using a better form plugin? Both Ninja Forms and Gravity forms are excellent.

share|improve this answer
    
I'm actually using gravity forms, but it's possible that there are other things there (I inherited this site from another developer = fun!) –  user3515 Mar 6 at 21:04
    
I just searched my entire site's files for '#input_38_7', and didn't find it! Odd! –  user3515 Mar 6 at 21:05
    
I found similar stuff in wp-content\cache. Am I allowed to delete files in there? –  user3515 Mar 6 at 21:27
    
So strange! I cleared out the cache, and I'm still seeing that error in the console. Any ideas where on earth it could be coming from? Thanks! –  user3515 Mar 6 at 21:54
    
Did you check your theme? Try reverting to TwentyFourteen for a second. Try searching your site's files for attr('placeholder') or just placeholder. –  helgatheviking Mar 6 at 22:12

This is not related to WordPress, I guess moderators are in a good mood. Anyway this error can happen when a script that needs jQuery is enqueued before jQuery. The solution might be to use the parameter $deps of wp_enqueue_script() :

wp_enqueue_script( $handle, $src, array('jquery'), $ver, $in_footer );;

See this link

EDIT : See helgatheviking's answer. It might be due to a script added in header.php or a function hooked on wp_head() with a very high $priority (under 10)

share|improve this answer
    
Thanks for answering. I don't understand why this is not related to wp, but whatever. I added array('jquery') to where I'm enqueueing that script, but I still get the error in the console. Any advice? –  user3515 Mar 6 at 20:50
    
I've edited answer. Do not forget to empty cache if your site cache for known users. –  JMau Mar 6 at 20:54
    
Do I need to register each script twice, then? –  user3515 Mar 6 at 20:56
    
not at all. My mystake, I've put this on the wrong topic. Fixed now. –  JMau Mar 6 at 20:57
    
OK> I will empty the site cache and try again. Thanks –  user3515 Mar 6 at 20:59

Just updated WP and reset all plugins, and it looks like the issue is gone. Thanks to everyone for being so helpful along the way!!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.