AJAX 400 Bad Request Worpress PHP

Solution:

There are two action hooks when you hook into wp_ajax.

  • wp_ajax_{$action} for for logged-in users. Docs

and

  • wp_ajax_nopriv_{$action} for logged-out users. Docs

So to combine the two, you could use the following code:

add_action( 'wp_ajax_get_content_wino' , 'get_content_wino' );

add_action( 'wp_ajax_nopriv_get_content_wino' , 'get_content_wino' );

function get_content_wino()
{
   if ( isset($_REQUEST) )
   {
       echo read_file();
       die();
   }
}