0
votes

Hy,have problem with ajax, in zend framework, ajax call function get send ../funct/param , in pole are corect informations, but ajax have problem

thanx for help :) here is php action code-

 public function obsadenakartaAction() {

        $parametr = $this->params()->fromRoute('parram', 0);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
        curl_setopt($ch, CURLOPT_URL, 'http://0.0.0.0:5552/getCardInfo?cardSNR=' . $parametr);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
        $data = curl_exec($ch);
        $pole = json_decode($data, TRUE);
        $model = new JsonModel(array('pole'=> $pole));
        return $model;
    }
 in $pole is array
ajax -

$.ajax({

                    type: "GET",
                    url: '/cards/obsadenakarta/5',
                    contentType: "application/json",
                    //data: data //JSON.stringify({ lineFilter: "" });
                })
                .done(function (data)
                {
                    console.log(data);
                    alert(data);

                });

And Error is :

Fatal error Uncaught exception 'Zend\View\Exception\RuntimeException' with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render template "application/cards/obsadenakarta"; resolver could not resolve to a file' in /opt/wertyz/apps/cards/vendor/zendframework/zend-view/src/Renderer/PhpRenderer.php:493 Stack trace: 0 /opt/wertyz/apps/cards/vendor/zendframework/zend-view/src/View.php(205): Zend\View\Renderer\PhpRenderer->render(Object(Zend\View\Model\JsonModel)) 1 /opt/wertyz/apps/cards/vendor/zendframework/zend-mvc/src/View/Http/DefaultRenderingStrategy.php(103): Zend\View\View->render(Object(Zend\View\Model\JsonModel)) 2 [internal function]: Zend\Mvc\View\Http\DefaultRenderingStrategy->render(Object(Zend\Mvc\MvcEvent)) 3 /opt/wertyz/apps/cards/vendor/zendframework/zend-eventmanager/src/EventManager.php(444): call_user_func(Array, Object(Zend\Mvc\MvcEvent)) 4 /opt/wertyz/apps/cards/vendor/zendframework/zend-eventmanager/src/EventManager.php(205): Zend\EventManager\EventManager->triggerListeners('render.erro in /opt/wertyz/apps/cards/vendor/zendframework/zend-view/src/Renderer/PhpRenderer.php on line 493

1

1 Answers

0
votes

You need to disable your view from rendering. Add this line to your action Cards/Obsadenakarta

$this->_helper->viewRenderer->setNoRender(true);