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

WordPress Ajax JSON success return no being recognized

You are not giving the action name to your AJAX call. In WordPress, you have to give an action name, the same name you give whatever is after wp_ajax_ and wp_ajax_nopriv_ In this case, the AJAX call should work if you change the data: inside your AJAX call, for this: data: {action: “contactform_action”, values: $(‘#contact-form’).serialize()} … Read more

AJAX Post from same domain to a wordpress page

First, WordPress has a built-in way to handle AJAX requests, you should read this page and use that method instead. The issue with your method is that you’re POSTing the name var. name is a WordPress query var, and is causing WordPress to query for a page with slug John. Always prefix your vars with … Read more