• Resolved jinzo

    (@jinzo)


    Hi,

    I’m using CF7 on a site, where one form doesen’t have a CF7 submit button, but I submit the form with Javascript/jquery .submit(). It works as expected, but when I enable this plugin it does two XHR requests instead of one.
    I double checked, and I’m calling the submit() only once. Other “ordinary” forms work OK.

    So I guess it has to do something with the custom JS of this plugin? I tried looking in this plugin but didn’t find anything interesting. Any ideas where the problem could be?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    can you link the page where this is happening?

    Plugin Author Aurovrata Venet

    (@aurovrata)

    one form doesen’t have a CF7 submit button, but I submit the form with Javascript/jquery .submit().

    what triggers your submit script?

    Thread Starter jinzo

    (@jinzo)

    Another button (let’s call it “next”), that calls a JavaScript function that basicly does $(‘#my-form’).submit(); and some other trivial calls. I triple checked and this function get’s called only once 100%. Also if I disable this plugin, everything works as expected. No other changes needed.

    Unfortunately I cannot link the page currently, will try to set it up somewhere

    Plugin Author Aurovrata Venet

    (@aurovrata)

    reposting—can you link the page where this is happening?

    Unfortunately I cannot link the page currently, will try to set it up somewhere

    missed that… If you can that would be helpful. Otherwise, can you send me a copy of your form to vrata at syllogic dot in and I will test this on my local server see if I can throw some light on this

    Plugin Author Aurovrata Venet

    (@aurovrata)

    I did a quick test on my local server with a anchor link as a submit button and fired the form submit as follows,

    $(document).ready(function(){
        $('#submit').on('click', function(){
        var form = $(this).closest('form');
        form.submit();
        });
      })
    

    and it submits only once. So its all working as expected.

    Is it possible that another plugin/script is interfering with your form?

    Also if I disable this plugin, everything works as expected. No other changes needed.

    the plugin creates an additional layer of wrapper around the cf7 form,

    
    <div class="cf7sg-container">
      <div id="cf7sg-form-ui-form" class="cf7-smart-grid has-nice-select has-validation has-select2 has-accordion has-effects has-grid has-date key_ui-form">
      [...]
      </div>
    </div>
    

    and maybe something else if interfering with the additional markup.

    What are the other plugins you are using that load scripts on your form page?

    Thread Starter jinzo

    (@jinzo)

    Hi,

    thanks for the tips – I found the fault. For some reason I was initialising the CF7 form in JS (with wpcf7.initform). I don’t remember why exactly, but after I stopped doing that, everything started working as expected.

    Thanks for your help and pointers!

    Plugin Author Aurovrata Venet

    (@aurovrata)

    oh good. Glad you sort it out.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Double submit when using JS for form submission’ is closed to new replies.