Ajax call theme functions from front
I think that your problem is ajaxurl is not available for your script. Try to defined that varibale before your js code is loaded. The best way is using wp_localize_script: The PHP: add_action( ‘wp_enqueue_scripts’, ‘cyb_enqueue_scripts’ ); function cyb_enqueue_scripts() { //Change the key and url with yours wp_register_script(‘my-js’, get_stylesheet_directory_uri(). ‘/js/my-js.js’, array( ‘jquery’ ) ); wp_enqueue_script(‘my-js’); //Localize … Read more