Ajax contact form returnig 0

What makes you think this will ever be true? if (isset($_POST[‘submit’])){ In function dav_form_validation the die() is in 2 conditionals. It should be called regardless of whether the conditionals are satisfied. Add 2 else clauses and return error messages. Usually a response of ‘0’, means the ajax hooks are not being found. But your code … Read more

First time doing Ajax with WP, how to do it?

$(‘#shoes-kids’).on(‘change’, function(){ $.post(‘<?php echo admin_url( “admin-ajax.php” ); ?>’, { first_name: “”+ $(“#first_name”).val(), //sending first name last_name: “”+ $(“#last_name”).val(), //sending last name action : ‘your_ajax_hook’ }, function(data,status){ if(status==”success”) { $(“#product-results”).append(data); } else { alert(‘Failed’); } }); }); i.e:- add_action( ‘wp_ajax_your_ajax_hook’, ‘your_function_name’ ); add_action( ‘wp_ajax_nopriv_your_ajax_hook’, ‘your_function_name’ ); In above I have send first_name and last_name as a … Read more