You should this way to handle ajax request. It’s the recommended way to make a ajax call in WordPress.
my_function.js
Update your jquery
with this code.
jQuery(document).ready(function($) {
$('#submit_payment').click(function(e){
e.preventDefault();
var str = $("form[name=season-form]").serialize();
//alert(str);
$.ajax({
type: "POST",
url: '//www.example.com/wp-admin/admin-ajax.php',
data: str + '&action=confirmRequest'
}).done(function(data){
$("#result").html(data);
});
});
});
ajax_request_handling
Paste this in functions.php
of your theme.
function _myConfirmHandler()
{
if(isset($_POST['vehicle_no']))
{
$vehicle_no = $_POST['vehicle_no'];
$email = $_POST['email'];
echo "Your Data: <br>$vehicle_no <br>$email<p />";
}
echo do_shortcode('[cfdb-table form="season parking form_copy"]');
echo do_shortcode('[contact-form-7 id="23" title="Contact form 1"]');
exit;
}
add_action('wp_ajax_confirmRequest', '_myConfirmHandler');
add_action('wp_ajax_nopriv_confirmRequest', '_myConfirmHandler');
For more information refer to the link.