1. Open function.php file and paste the below code to deined wordpress ajaxurl
/*defined ajax url*/
add_action('wp_head', 'wordpress_frontend_ajaxurl');
function wordpress_frontend_ajaxurl() {
echo '<script type="text/javascript">
var ajaxurl = "' . admin_url('admin-ajax.php') . '";
</script>';
}
add_action('wp_head', 'wordpress_frontend_ajaxurl');
function wordpress_frontend_ajaxurl() {
echo '<script type="text/javascript">
var ajaxurl = "' . admin_url('admin-ajax.php') . '";
</script>';
}