• Resolved JudahsMom63

    (@judahsmom63)


    I added this code to my child functons.php:

    ‘// enqueue jquery
    function load_jquery() {
    wp_enqueue_script( ‘jquery’ );
    }
    add_action( ‘wp_enqueue_scripts’, ‘load_jquery’ );

    // add custom javascript file
    function load_scripts(){
    wp_register_script(‘topline’, get_stylesheet_directory_uri() . ‘/script/topline.js’, array(‘jquery’), false);
    wp_enqueue_script(‘topline’);
    }
    add_action(‘wp_enqueue_scripts’, ‘load_scripts’);’

    In my child header.php I added this:

    ‘<script type=’text/javascript’ src=”<?php echo get_stylesheet_directory_uri(); ?>/script/topline.js”></script>’

    I have cleared my cache and deactivated all of my plugins. The only result was more reference errors. I managed to get WP to find my topline.js file in my child theme folder. I did not do <script>etc.jQuery</script> in my child header.php because I thought jQuery came with WP. Please tell me what I am doing wrong. Thank you. P.S. Sorry the post is so long.

Viewing 15 replies - 1 through 15 (of 17 total)
  • You don’t need this line

    <script type='text/javascript' src="<?php echo get_stylesheet_directory_uri(); ?>/script/topline.js"></script>

    in your header.php because wp_enqueue_script() takes care of that for you. Can you post a link to your site?

    Thread Starter JudahsMom63

    (@judahsmom63)

    Stephen, I’m afraid not. I’m working on a localhost, I’m going to go try your suggestion & get back to you.

    Thread Starter JudahsMom63

    (@judahsmom63)

    @stephencottontail – Thanks so much for your reply!! The good news is the jquery undefined error is gone. The bad news is, this new error message replaced it.

    localhost/:196 Uncaught TypeError: Cannot read property ‘tagName’ of null

    I have no clue what this is or where to find it. Any suggestions?

    Unfortunately, it’d be extremely difficult to tell without seeing a live site. What theme are you using? Does the error go away if you switch themes? Does the error go away if you temporarily remove the new script you added?

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    The bad news is, this new error message replaced it.

    localhost/:196 Uncaught TypeError: Cannot read property ‘tagName’ of null

    So it’s referring to line 196 of your source code. What line is that?
    Right click on the page and select ‘view source’

    Thread Starter JudahsMom63

    (@judahsmom63)

    I took my folder out of my child theme folder, refreshed my WP page (got a GET message) then I put the folder back into my child theme and NO ERRORS! Thanks so much! I’m using my own theme (aka a Frankenstein-ing of an older theme) but fortunately switching themes won’t be necessary.

    I hope.

    Thanks again so much for your help! I’m working hard to learn developing and Wordpresing and appreciate your assistance.

    Thread Starter JudahsMom63

    (@judahsmom63)

    @andrew – I did check to see what line 196 was of the source code. It’s a huge line of code from the slider plugin I installed. Trying to find ‘tagName’ in all that code would probably been impossible for a noob like me. Hopefully, though, I won’t have to deal with it! Thanks for showing me how to find it, though. I really appreciate it!

    One thing I’ve learned: I like Chrome’s debugger better than Firefox’s.

    Thanks again!

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Copy the giant line of code at line 196,
    Put it into this beautifier tool: https://jsbeautifier.org/ ,
    Copy all of the beautified code,
    Paste it into PasteBin: https://pastebin.com ,
    Link us the PasteBin file please

    Thread Starter JudahsMom63

    (@judahsmom63)

    @andrew: Here’s the link: https://pastebin.com/W9ZYZ1Nk

    Here’s the paste title: JudahsMom63 Line 196

    Thank you for showing me these. They are great tools for a developer-in-development.

    Also, thanks for wanting to take a look at the source code.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    So your error only occurs when you mouse over the slider?

    Thread Starter JudahsMom63

    (@judahsmom63)

    Yes. I have 4 “sliders” on this page, but three of them are galleries and of those three, only one of them has navigation buttons. None of those three show error messages when moused over. This fourth one is the only one that plays automatically, and the more you mouse over it, the more error messages you get.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Yeah we can’t debug this without the site – anyway did you find out the plugin responsible? Is it a plugin distributed on www.ads-software.com?

    Thread Starter JudahsMom63

    (@judahsmom63)

    Yes. Slider WD by Web Dorado. I’ll contact them and tell them about this problem.

    Is there any way to take this to a “live” site while it’s still in development stage? I’m doing this for someone else and they don’t want it seen until it’s done.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    You could set up a subdomain through your hosting provider’s control panel and maybe use a plugin to duplicate your site there: https://www.ads-software.com/plugins/duplicator/

    The subdomain can be password protected

    Thread Starter JudahsMom63

    (@judahsmom63)

    I’m going to research this further. Thanks so much for everything you’ve taught me today. I appreciate it more than you know.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘jQuery is not defined error’ is closed to new replies.