How To make simple jQuery Ajax in cakephp 3.7

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';