Ajax resetting my global variable

Each time you’re making an ajax call, $_TEST = 0; is being evaluated again. You use the options API to manipulate your variable.

function get_global_val() 
{
   $count = get_option( 'mycount' );
   $count++; //or whatever you want to do with it
   update_option( 'mycount', $count );
   die("New value is $count");
}