Failed to open stream: success on ajax request in opencart

I have day after day with no luck. Can anyone please help?

I have an AJAX request that loads more categories on the home page. Code

$json=array();
$template = new Template();
$template->data['categories'] = $this->data['categories'];
$html = $template->fetch($this->config->get('config_template') . '/template/common/category_load.tpl');
$json['success'] = $html;
$json['output'] = $this->render();
$this->response->setOutput(json_encode($json));

      

While I test the function, it gives the correct output. But when trying to load via AJAX, it gives an error saying

failed to open stream: Success at /var/www/html/boomrc/system/engine/controller.php on line 82

Did I make some mistake? I am new to OpenCart.

+3


source to share


2 answers


if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/category_load.tpl')) {
                    $this->template = $this->config->get('config_template') . '/template/common/category_load.tpl';
            } 


            $json['content'] = str_replace("\r\n", "", $this->render());
            echo json_encode($jdata);

      



Try it.

+1


source


Please use Browser-Debug-Console. Make sure you are not doing a cross domain request for your ajax. There are some security restrictions so you cannot make cross domain request for ajax.



Maybe put your controlle.php (or simplified code) here.

0


source







All Articles