Title: Trigger Ajax form submit by Javascript
Last modified: June 4, 2020

---

# Trigger Ajax form submit by Javascript

 *  Resolved [furlosk](https://wordpress.org/support/users/furlosk/)
 * (@furlosk)
 * [5 years, 12 months ago](https://wordpress.org/support/topic/trigger-ajax-form-submit-by-javascript/)
 * Hello,
    I have a Forminator form which has all the fields pre-filled from URL
   query and should submit itself automatically after page load. How should I accomplish
   this?
 * I tried calling this:
    `document.getElementById('forminator-module-468').submit()`
   which works, but it ignores form validation and submits the form even if some
   required field is not filled. Moreover, it seems that this method does not use
   Ajax, but instead reloads the entire page.
 * How to emulate “normal” form submit, i.e. a normal user click on submit button,
   which firstly checks if all fields are properly filled in, and only if everything
   validates, submits the form via Ajax and displays result above the form? Note
   that I have set the form submission method to Ajax.

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

 *  Thread Starter [furlosk](https://wordpress.org/support/users/furlosk/)
 * (@furlosk)
 * [5 years, 12 months ago](https://wordpress.org/support/topic/trigger-ajax-form-submit-by-javascript/#post-12936880)
 * Hah,
    as it usually happens, I found the solution just after I submitted the 
   question!
 * Turned out that the problem can be solved by using this custom HTML code below
   the form itself:
 * >  <script type=”text/javascript”>
   >  //jQuery(document).ready(function() { jQuery(
   > window).on(‘load’, function() { jQuery(‘#submit button’).click(); }); </script
   > >
 * Note that using `jQuery(document).ready()` function causes the code to be executed
   after the DOM is loaded, but before the form is fully initialised. If you want
   to have form validate the fields and prevent submission if something does not
   validate, you must use `jQuery(window).on('load')` function.
 *  Plugin Support [Laura – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support8/)
 * (@wpmudev-support8)
 * [5 years, 12 months ago](https://wordpress.org/support/topic/trigger-ajax-form-submit-by-javascript/#post-12940819)
 * HI [@furlosk](https://wordpress.org/support/users/furlosk/)
 * I’m happy to hear that you have found solution!
 * I’m sure a lot of people will find that useful in future so thanks fo rsharing
   it 🙂
 * Best regards,
    Adam

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

The topic ‘Trigger Ajax form submit by Javascript’ is closed to new replies.

 * ![](https://ps.w.org/forminator/assets/icon-256x256.gif?rev=3443182)
 * [Forminator Forms – Contact Form, Payment Form & Custom Form Builder](https://wordpress.org/plugins/forminator/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/forminator/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/forminator/)
 * [Active Topics](https://wordpress.org/support/plugin/forminator/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/forminator/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/forminator/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Laura – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support8/)
 * Last activity: [5 years, 12 months ago](https://wordpress.org/support/topic/trigger-ajax-form-submit-by-javascript/#post-12940819)
 * Status: resolved