The error is from Cake\View\Exception\MissingTemplateException; “the view for CountriesController::stateslist() was not found.”
I didn’t think it would need a view because the purpose of this controller action is simply to serve data. To try and rectify this, I added:
return $this->response;
to the last line of the “public function stateslist() {” function.
Now I get no error, but the dropdown still doesn’t update. I’m guessing this means there’s an error either in my database queries or in my AJAX – i.e. the data isn’t being requested in the controller function, or is being requested but isn’t being passed back. I’d really appreciate suggestions on where the errors in my code might be.