$countryId=parseInt(countrId);
This is in your javascript. The value isn't passed into PHP.
IF you look at the javascript code output, you'll see something like:
$countryId=parseInt(countrID);
so your JAVASCRIPT has a variable called $countryId -- but PHP doesn't know about it.
If $countryId is floating around as some sort of query variable, either from a url ($GET) or form ($POST) you're going to have get it into the <? PHP ?> like this:
$query="SELECT * FROM states WHERE CID=".$_REQUEST['countryId'];