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.

Error Messages Don't Show On Ajax Submissions

  1. Having a weird issue: When submitting via Ajax, no error messages display. Everything displays fine when not submitting via Ajax. If I check via Firebug, it looks like the HTML is getting added to the page but the iframe does not display. Also checking via Firebug I don't see any javascript errors. I've tried disabling all plugins and still no joy. You can see the form at http://lumenergi.dreamhosters.com/contact/

    Is there a typical cause for this type of thing?

    Thanks in advance,
    --eric

    Posted 12 years ago on Wednesday May 11, 2011 | Permalink
  2. You are getting a Javascript error. See this screenshot: http://grab.by/a6qQ

    The problem is you are calling jQuery in your Footer.php and not your Header.php.

    The AJAX call uses some inline jQuery that requires jQuery to be loaded in order to execute. Because your jQuery is loaded in your Footer.php that means jQuery is loaded AFTER this script tries to execute, causing an error.

    You need to move your jQuery call to your Header and not your Footer.

    You also may run into a problem because you are using Google's API to call jQuery instead of using the jQuery that ships with WordPress. We haven't tested with Google's API because it relies on the version of jQuery that ships with WordPress. I'm not saying it will cause a problem, just that it might cause a problem.

    But your issue is where you are calling jQuery.

    Posted 12 years ago on Wednesday May 11, 2011 | Permalink
  3. Gotcha - That makes sense!

    One question: Since loading JavaScript in the bottom of a page is considered a best practice, I'm wondering if there's a way to force all Gravity Forms scripts to load in the footer too...

    Posted 12 years ago on Wednesday May 11, 2011 | Permalink
  4. There is no way. Loading MOST javascript at the bottom of a page is best practice. Loading the core jQuery library itself? Only doable if you have 100% control over the site such as when using sites that use no CMS (ie. hardcoded HTML). Plugins and Themes that rely on jQuery are going to run into an issue if they try to do something expecting jQuery to already be loaded and it is not there. Default WordPress and the themes it ships with place jQuery in the header and that is what plugins are designed for.

    Posted 12 years ago on Wednesday May 11, 2011 | Permalink
  5. Shame we can't force everything into the footer - I always hate seeing YSlow grades that aren't A's :D

    In any case, thanks for spotting that. Loading jQuery first fixed the issue. And you should know the Google hosted version of jQuery plays nicely with Gravity Forms. Rock-solid plugin, guys!

    Best,

    --eric

    Posted 12 years ago on Wednesday May 11, 2011 | Permalink

This topic has been resolved and has been closed to new replies.