My ajax is altering form action/URL thus makes me impossible to read the $tid from it
At the very end, you could use a variable_set on if(!empty(arg(1))) and retrieve it with variable_get on if(empty(arg(1))), but I'm sure there's a cleaner way.