Then there seems to be something wrong with the route itself.
Could you show us the output Javascript as seen by the browser?
var targeturl = '<?= Router::url(["controller"=>"homes","action"=>"getStates"]); ?>';
should become something like:
var targeturl = 'www.mydomain.tld/home/getstates';