Core/Framework/Amvc/Controller/Controller.php
public function ajax($selector = '#content')
    {
        $this->ajax = $this->di->get('core.ajax');

        $cmd = new DomCommand($selector, 'html', '--empty--');

        // Prepare a fresh ajax command object
        $this->ajax_cmd = $cmd;

        // Get content from Controller::run()
        $content = $this->run();

        if ($content !== false) {

            $this->ajax_cmd->setArgs($content);
            $this->ajax_cmd->setId(get_called_class() . '::' . $this->action);

            if (empty($this->ajax_cmd->getSelector()) && !empty($selector)) {
                $this->ajax_cmd->setSelector($selector);
            }

            $this->ajax->addCommand($this->ajax_cmd);
        }
    }
public function ajax($selector = '#content')
    {
        $this->ajax = $this->di->get('core.ajax');

        $cmd = new DomCommand($selector, 'html', '--empty--');

        // Prepare a fresh ajax command object
        $this->ajax_cmd = $cmd;

        // Get content from Controller::run()
        $content = $this->run();

        if ($content !== false) {

            $this->ajax_cmd->setArgs($content);
            $this->ajax_cmd->setId(get_called_class() . '::' . $this->action);

            if (empty($this->ajax_cmd->getSelector()) && !empty($selector)) {
                $this->ajax_cmd->setSelector($selector);
            }

            $this->ajax->addCommand($this->ajax_cmd);
        }
    }
public function ajax ( $ selector = '#content' ) { $ this -> ajax = $ this -> di -> get ( 'core.ajax' ) ; $ cmd = new DomCommand ( $ selector , 'html' , '--empty--' ) ; // Prepare a fresh ajax command object $ this -> ajax_cmd = $ cmd ; // Get content from Controller::run() $ content = $ this -> run ( ) ; if ( $ content !== false ) { $ this -> ajax_cmd -> setArgs ( $ content ) ; $ this -> ajax_cmd -> setId ( get_called_class ( ) . '::' . $ this -> action ) ; if ( empty ( $ this -> ajax_cmd -> getSelector ( ) ) && ! empty ( $ selector ) ) { $ this -> ajax_cmd -> setSelector ( $ selector ) ; } $ this -> ajax -> addCommand ( $ this -> ajax_cmd ) ; } }
Ajax method to send the result of an action as ajax html command

This works similiar to the run() method and even uses it. The difference is that the renderesult is wrapped by an
ajax command object. This ajax command can be controlled by setting the wanted parameters via $this->ajax->...

@param string $selector
Optional jQuery selector to html() the result.
Can be overridden by setAjaxTarget() method.
Default: '#content'
Ajax method to send the result of an action as ajax html command