Fatal error: Uncaught Error: Call to undefined function wp_nav_menu()
Yes, like @fuxia says, include wp-load.php to get the WordPress API (wp_nav_menu included) to use. In your case: <?php include ‘../../../../wp-load.php’; This way you did is not wrong but there are better ways to use AJAX in WordPress: https://codex.wordpress.org/AJAX_in_Plugins Be happy, my friend!