I am developing an e-commerce website with the best shop Magento 2 theme with VES brand Magento 2 extension, its working fine when we open any brand pages and then click on toolbar sorting and pagination it is not working, I found that the ajax response all HTML instead of JSON response, so I write a code for JSON response but this gives me the following error, please help me with that
$isAjax = $this->getRequest()->isAjax();
if ($isAjax){
$this->layerResolver->create(Resolver::CATALOG_LAYER_SEARCH);
$this->_view->loadLayout();
$navigation = $this->_view->getLayout()->createBlock('catalogsearch.leftnav');
$products = $this->_view->getLayout()->createBlock('search.result');
$result = [
'products' => $products->toHtml(),
'navigation' => $navigation->toHtml()
];
Uncaught Error: Call to a member function toHtml() on boolean in /var/www/html/brands/app/code/Ves/Brand/Controller/Brand/View.php:149
please check following link