wp_ajax action is not running

Where are you calling add_action()? If it’s in a place where you’re already outputting HTML, it’s too late, and that’s probably a place that wont even be looked at during an AJAX request.

You should include that code in your theme’s functions.php file, or as early as possible in a plugin.