Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How to prevent Controller from sending view

I'm communicating with my controller via AJAX and requesting an action. But depending to the result on the said controller, I want it to return particular values, but by now it return a whole "index" template.

I just want it to return what I say it to return. How can I do that?


// In some view...
$.post('my/action', send, function(res){
    // 'res' variable should be 'true' or 'false', not the whole View html, etc...

edited Sep '14
$response = new Phalcon\Http\Response(),

// Do things here.
$varWithThingsDone = 'Doing things.';

    'response' => $varWithThingsDone

You might want to know that you can also check if the post is from AJAX:


@RompePC perfect, worked like a charm, thanks.