I want to send an Ajax request to the controller, I do it on the client side
jQuery.ajax({ url: "public/visits/visit/get-visits", type: "POST", dataType: 'json', data: data, success: function(data){ alert(data) }, error:function(){ alert("fail :("); } });
on the server side, I process the request like other requests
public function getVisitsAction() { if (isset($_POST)) { $mapper = new Visits_Model_VisitsMapper(); $allVisits = $mapper->getAllVisits(); echo json_encode($allVisits); }
When I call the action, an error message appears, and when I check it by mistake, I find that it returns client-side json data to the get-visit.phtml page.
How can I process the response in a success function from a page that sends a json request and redirects it to the get-visit.phtml page?
source share