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.

Two forms on a page, and ajax only works on one of them.

  1. Hi,

    I have two forms on one of the pages on my site. Ajax doesn't work on the first form, but does on the second.

    The page can be seen here: http://www.rocksoliddesigns.co.uk/about/contact-us/

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  2. Richard Vav
    Administrator

    Hi Olly,

    Chrome is reporting a couple of javascript errors

    Uncaught SyntaxError: Unexpected number http://www.rocksoliddesigns.co.uk/:250
    Uncaught SyntaxError: Unexpected identifier http://www.rocksoliddesigns.co.uk/:376

    Can you try testing for a theme/plugin conflict to narrow down the problematic script.

    Regards,
    Richard

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  3. It seems to be something in the theme, because there's no issue if I switch to twentyten.

    The unexpected identifier was from the cookie control plugin, but i'm still getting the unexpected number with all the plugins disabled.

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  4. Richard Vav
    Administrator

    If it's something in the theme then the next step is to comment out the scripts included by the theme one at a time to try and narrow it down further.

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  5. I've done that now, as far as I can tell i've deactivated all the other scripts, i've deactivated all the plugins, including the mailchimp addon, so the only plugin running is gravity forms, and the form still won't use ajax.

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  6. Richard Vav
    Administrator

    Can you switch the theme again, I want to compare the Gravity Forms script beneath the form to see if it is being modified by the theme in anyway.

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  7. Done!

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  8. Richard Vav
    Administrator

    Thanks, you can switch it back, I will get back to you once I have gone through and compared the scripts.

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  9. Richard Vav
    Administrator

    OK found it, something in your theme, probably in the functions.php file is adding an unwanted space. This is an excerpt from the script beneath the form when using your theme

    var is_form = !(form_content.length < = 0 || is_redirect);

    and this is what it should be

    var is_form = !(form_content.length <= 0 || is_redirect);

    Can you try wrapping your form in [raw] [/raw] tags to see if that makes any difference.

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  10. Thanks, not sure what you mean by wrapping the form in [raw] tags though.

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  11. Richard Vav
    Administrator

    So if you edit that page I presume you have a form embed code, wrap the code in the raw tags so it looks something like this

    [raw][gravityform id="1" name="ajax form" ajax="true"][/raw]
    Posted 10 years ago on Monday July 8, 2013 | Permalink
  12. Ok, I thought that's what you meant, tried it, but the shortcodes just appear on the screen.

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  13. Richard Vav
    Administrator

    Sorry about the delay, could I get a look at your themes functions.php file, you can copy it to Pastie or PasteBin, the links are above the reply box.

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  14. functions.php is here:

    http://pastebin.com/6V3AnwLz

    and this file bones.php is included.

    http://pastebin.com/1hDVX1cX

    Posted 10 years ago on Monday July 8, 2013 | Permalink
  15. Richard Vav
    Administrator

    I can't see anything in those two files that could be adding the extra space, however it looks like the functions file does include a number of other files.

    Posted 10 years ago on Tuesday July 9, 2013 | Permalink
  16. I've narrowed it down to the force_balance_tags in this:

    add_filter('the_content', 'remove_empty_p', 20, 1);

    function remove_empty_p($content){
    $content = force_balance_tags($content);
    return preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content);
    }

    I've stopped calling it as a filter, and i'm now using it where I need it directly, and it seems to have fixed the problem.

    Thanks for all your help.

    Posted 10 years ago on Tuesday July 9, 2013 | Permalink
  17. Richard Vav
    Administrator

    You're welcome, and I am glad you have figured it out.

    Posted 10 years ago on Tuesday July 9, 2013 | Permalink

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