Ajax in wordpress [duplicate]
Write below code in functions.php of your active theme <script type=”text/javascript” > jQuery(document).ready(function($) { var data = { ‘action’: ‘get_data’, ‘testparam’:’hello’ //optional to pass any extra param }; $.ajax(ajaxurl, data, function(response) { alert(‘Response: ‘ + response); //Append response in your result wrapper }); }); </script> <?php add_action( ‘wp_ajax_get_data’, ‘get_data_ajax_func’ ); function get_data_ajax_func() { global $wpdb; … Read more