PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

jQuery not defined

  1. I have searched the forums for this problem and seen several related topics. But none seem to indicate a solution that helps me. I'm using the Twenty Ten 1.2 theme and have created a separate file that is require_once in the functions.php. This file contains the simple shell specified in the Usage for Gform post render documentation (http://www.gravityhelp.com/documentation/page/Gform_post_render) as I just want to see that I'm placing the JavaScript in the correct place. But I get a "jQuery is not defined" error in Firebug. My short code for my first Gravity form is in a page like this [gravityform id=1 name=AskALibrarian ajax=true]. I can see that jQuery version 1.4.4 is loading in the header. I tried changing the jQuery at the start to $ but this produces the same kind of error. FYI, the form loads fine.

    Posted 12 years ago on Wednesday February 22, 2012 | Permalink
  2. Richard Vav
    Administrator

    Can you post a link to the page with your form on it?

    Posted 12 years ago on Thursday February 23, 2012 | Permalink
  3. Unfortunately, we are developing the new site on a server behind a firewall. So I can't provide a link that will get you to it. Does seeing this code from the head of the page help?

    <script type="text/javascript">
    // This file is included in the theme's functions.php file.
    jQuery(document).bind('gform_post_render', function(){
    // code to trigger on AJAX form render
    });
    </script>
    <meta charset="UTF-8">
    <title>Ask A Librarian Test | University of Virginia Library</title>
    <link href="http://gmpg.org/xfn/11" rel="profile">
    <link href="http://finch.lib.virginia.edu/wordpress/wp-content/themes/twentyten/style.css" media="all" type="text/css" rel="stylesheet">
    <link href="http://finch.lib.virginia.edu/wordpress/xmlrpc.php" rel="pingback">
    <meta content="noindex,nofollow" name="robots">
    <link href="http://finch.lib.virginia.edu/wordpress/feed/" title="University of Virginia Library » Feed" type="application/rss+xml" rel="alternate">
    <link href="http://finch.lib.virginia.edu/wordpress/comments/feed/" title="University of Virginia Library » Comments Feed" type="application/rss+xml" rel="alternate">
    <link href="http://finch.lib.virginia.edu/wordpress/ask-a-librarian-test/feed/" title="University of Virginia Library » Ask A Librarian Test Comments Feed" type="application/rss+xml" rel="alternate">
    <link id="admin-bar-css" media="all" type="text/css" href="http://finch.lib.virginia.edu/wordpress/wp-includes/css/admin-bar.css?ver=20110325" rel="stylesheet">
    <script src="http://finch.lib.virginia.edu/wordpress/wp-includes/js/l10n.js?ver=20101110" type="text/javascript">
    <script src="http://finch.lib.virginia.edu/wordpress/wp-includes/js/comment-reply.js?ver=20090102" type="text/javascript">
    <script src="http://finch.lib.virginia.edu/wordpress/wp-includes/js/jquery/jquery.js?ver=1.4.4" type="text/javascript">
    Posted 12 years ago on Thursday February 23, 2012 | Permalink
  4. Solution recommended by one of my co-workers, which worked:
    Move the JavaScript out of the functions.php file and make a script tag after the wp_head() call, just before the </head> in the theme header.php file. This way the jQuery which is within the wp_head() output is defined before the JavaScript for something like Gform post render. This did get rid of the jQuery not defined error.

    This just confuses me a bit because the Gform post render documentation says to put the JS into the theme's functions.php file and the twentyten theme has comments indicating not to add script tags after the wp_head() call as it can possibly break WP.

    Posted 12 years ago on Monday February 27, 2012 | Permalink