Question

Can someone explain to me why the following code isn't outputting anything in a component? Does the response object in a component behave differently from that in an action (since the code works as part of an action)?

I am using Symfony 1.4.

$this->getResponse()->setContent("OK");

Code block:

class merchantComponents extends sfComponents
{
  .....
  public function executeAjaxrcmc(sfWebRequest $request)
  {
    $company_user_id = $this->getRequestParameter('ids');

    if(($company_user_id>0) && $request->isMethod('post'))
    {               
        $this->getResponse()->setContent("OK");
        return sfView::NONE;
    }
    else
    {
        $this->getResponse()->setContent("FAIL");
        return sfView::NONE;            
    } 
  }
....
}

Thanks in advance!

Was it helpful?

Solution

I think you probably need to send the content after setting it:

$this->getResponse()->sendContent();

Or, output it in a template file.

<?php echo $sf_response->getContent(); ?> 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top