Problem with ajax, function and contact form 7

by Lorena   Last Updated August 14, 2019 02:08 AM - source

I am trying to call contact form 7 through an Ajax call towards a defined function (which contains the html and do_shorcode of contact form 7), it is displayed correctly, but it seems not to work when sending the mail loads another page in White with a value 0,


function format_add_modal(){
echo ' 
<div class="reveal animated pulse" id="exampleModal1" data-reveal>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button class="close-button" data-close aria-label="Close modal" type="button">
    <span aria-hidden="true">&times;</span>
<h4 class="modal-title" id="myModalLabel">Form</h4>

<div class="modal-body">';
echo do_shortcode( '[contact-form-7 id="92" title="Contact form 1"]' );
echo ' 

add_action( "wp_ajax_nopriv_format_add_modal", "format_add_modal" );
add_action( "wp_ajax_format_add_modal", "format_add_modal");

and the jquery

jQuery(document).ready( function(e){

$('#my-button').one('click', function(){  
    type : "POST",

 url : '<?php echo admin_url( 'admin-ajax.php' ); ?>',
 data : {
 action : 'format_add_modal'
 error: function(response){
 success: function(response) {
    var modal = new Foundation.Reveal($('#exampleModal1'));;


Related Questions

Contact Form 7 If Condition

Updated March 19, 2019 12:08 PM

Using WordPress almost only for a contact form

Updated July 09, 2019 14:08 PM