Title: Output form via JavaScript vars doesn’t work
Last modified: August 31, 2016

---

# Output form via JavaScript vars doesn’t work

 *  [esemlabel](https://wordpress.org/support/users/esemlabel/)
 * (@esemlabel)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/output-form-via-javascript-vars-doesnt-work/)
 * Output the wpcf7 form via JavaScript vars doesn’t work.
 * For example, imagine some function “on click”
 *     ```
       jQuery('.some-button').on('click', function () {
           jQuery.dialog({
               content: new_vars.content
           });
       }
       ```
   
 * Then in php will add a Shotcode to this var
 *     ```
       wp_localize_script('some-script', 'new_vars',
           array( 'content' => do_shortcode('[contact-form-7 id="1"') )
       );
       ```
   
 * As result, the form will normally output as /* <![CDATA[ */ in html code and 
   will normally output visually.
    But the form will never work as expected! Validating
   data after hitting submit button will cause reload page instead of showing result.
 * The only way is to use direct echo do_shortcode without vars, but it’s not what
   I need.
    Hope you will add support in future for properly working form when it
   output from JavaScript var.
 * Thank you!
 * [https://wordpress.org/plugins/contact-form-7/](https://wordpress.org/plugins/contact-form-7/)

The topic ‘Output form via JavaScript vars doesn’t work’ is closed to new replies.

 * ![](https://ps.w.org/contact-form-7/assets/icon.svg?rev=2339255)
 * [Contact Form 7](https://wordpress.org/plugins/contact-form-7/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [esemlabel](https://wordpress.org/support/users/esemlabel/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/output-form-via-javascript-vars-doesnt-work/)
 * Status: not resolved