The first AjaxHandler Class example will not work becuase the execute function does not match the abstract base execute class.
Expected behavior
When I run an ajax call, the class returns the data array
Actual behavior
I get a 500 error.
PHP Fatal error: Declaration of Theme\AjaxHandler\MyAjaxHandler::execute() must be compatible with Conifer\AjaxHandler\AbstractBase::execute(): array in /app/wp-content/themes/Theme/lib/Theme/AjaxHandler/MyAjaxHandler.php
Solution
If you can update the example of the execute function to include the array return type, that would stop the issue.
protected function execute() : array {
/*
* Your custom logic goes here
* Request data is accessible via $this->request
* Return an array with the appropriate response data
*/
return ['example' => 'data'];
}
The first AjaxHandler Class example will not work becuase the execute function does not match the abstract base execute class.
Expected behavior
When I run an ajax call, the class returns the data array
Actual behavior
I get a 500 error.
Solution
If you can update the example of the execute function to include the array return type, that would stop the issue.