Contact Form 7 – Submit Form not working After Ajax Request

I am using Contact Form 7 with ajax jquery. The first part is for user to insert vehicle number and email.

If success, it will load contact form 7 via ajax. When I click on submit, it will redirect to a new page and will output 0. I had made a research on google and found out the wpcf7-submit function.

I tried to make an alert function and it response as expected. How do I want to use it with contact form 7 and email the form details if no error on the form?



// Include all the theme functions    

<form name="season-form" class="form-horizontal" method="post" action="">
  <div class="form-group form-group-lg">
    <label for="carNo" id="label-cust"> Vehicle Registration No</label>
    <input type="text" class="form-control" name="vehicle_no" id="vehicle_no" placeholder="BHK1991">
  <div class="form-group form-group-lg">
    <label for="email" id="email">Email</label>
    <input type="email" class="form-control" name="email" id="email" placeholder="">
  <button type="submit" class="btn btn-primary" id="submit_payment">Make Payment</button>
<div id="result"></div>

<?php get_footer(); ?>


function _myConfirmHandler()
        $vehicle_no = $_POST['vehicle_no'];
        $email = $_POST['email'];

        echo do_shortcode('[cfdb-table form="season parking form_copy" show="your-name,mail,your-platno,your-location" filter="your-platno=' . $vehicle_no . '" headers="your-name=Name,mail=Email,your-platno=Registration No.,your-location=Parking Location"]');

        // Display the Form 
        echo do_shortcode('[contact-form-7 id="6959" title="Payment season Form_Post"]');


add_action('wp_ajax_confirmRequest', '_myConfirmHandler');
add_action('wp_ajax_nopriv_confirmRequest', '_myConfirmHandler');


jQuery(document).ready(function($) {
        var str = $("form[name=season-form]").serialize();
            type: "POST",
            url: '//',
            data: str + '&action=confirmRequest' 

            showOn: "button",
            dateFormat: "dd-mm-yy",
                buttonImage: "",
                buttonImageOnly: true,
                showAnim: 'slideDown',
                duration: 'fast',
                showButtonPanel: true

            $('.wpcf7-submit').click(function(e) {
                alert('Submit button press!');


Do I have to rewrite the post method on the form and email the details if success?

Read more here: Contact Form 7 – Submit Form not working After Ajax Request

Leave a Reply

Your email address will not be published. Required fields are marked *