How to open contact form 7 by using wordpress ajax -


i using contact 7 plugin , question open contact form 7 in popup via wordpress admin ajax code not working. popup open contact form 7 not submitting. redirecting in admin ajax url , returns 0.

here code doing in functions.php

<?php add_action('wp_head', 'my_action_popup_cf7_javascript');  function my_action_popup_cf7_javascript() { ?> <script type="text/javascript" > jquery(document).ready(function($) {     $('.myajaxcarrer').click(function(){       //alert(1);       var mydata = $(this).data();       $(".overlay").fadein('slow');                var data = {             action: 'my_action_popup_cf7',             //whatever: 1234,             id: mydata.id         };         // since 2.8 ajaxurl defined in admin header , points admin-ajax.php         //console.log(ajaxurl);         $('.item').removeclass('active');         $('[data-id=' + mydata.id + ']').parent().addclass('active');         $.post('<?php echo esc_url( home_url() ); ?>/wp-admin/admin-ajax.php', data, function(response) {            // alert('got server: ' + response);            $('#testcarrer').html(response);             var offset = $(window).scrolltop();              $(".career-form").css("top", offset+50 );              $('.closebtn').click(function(e){               e.preventdefault();               $(".overlay").fadeout('slow');               $('.career-form').css("top", -1000+"%" )             });         });     }); });  </script> <?php }  add_action('wp_ajax_my_action_popup_cf7', 'my_action_popup_cf7_callback'); add_action( 'wp_ajax_nopriv_my_action_popup_cf7', 'my_action_popup_cf7_callback' );  function my_action_popup_cf7_callback() {      global $wpdb; // how access database      //$whatever = 'id=> '. $_post['id'];      //echo $whatever;      ?>      <a href="#" class="closebtn">x</a>       <h3>apply now</h3>       <div class="formbox">         <?php echo do_shortcode('[contact-form-7 id="905" title="my new carrer form"]'); ?>       </div>      <?php      exit(); // required return proper result & exit faster die(); } 

and code in page template file is

<span class="applybtn"><a class="myajaxcarrer" data-id="903">apply now</a></span>  <div class="overlay"></div> <div class="career-form">ajax result load here..</div> 

and js code below.

$('.applybtn').click(function(e){   e.preventdefault();   var offset = $(window).scrolltop();   $(".overlay").fadein('slow');    $(".career-form").css("top", offset+50 ) });  $('.closebtn, .overlay').click(function(e){   e.preventdefault();   $(".overlay").fadeout('slow');   $('.career-form').css("top", -1000+"%" ) }); 

you can open echoing do_shortcode('[form name id]'); in php function.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -