AJAX routing

how to make a route from Ajax request, that something like: $router->addAJAX("/products/edit/{id}", "Posts::edit"); or how?



83.4k

You can validate if the request is ajax in the action itself:

<?php

class PostsController extends Phalcon\Mvc\Controller 
{

    public function editAction()
    {

        if (!$this->request->isAjax()) {
            $this->flash->error('The request is not ajax');
            return;
        }

        //...
    }
}