Section: Generating plain text
« Generating HTML content | ^ Responses: generating content | Generating XML content » |
To create a jResponseText object, pass 'text' as argument to getResponse()
method in your controller's action.
jResponseText has a content
proprerty which should be assigned before output.
function myaction(){
$rep = $this->getResponse('text');
$rep->content = 'my text';
return $rep;
}
jResponseText returns "text/plain" Mime-Type by default, and uses jelix-configuration default charset.
jResponseText derives from jResponse, allowing you to modify HTTP headers such as Mime-Type or charset as well.
jResponseText can be used as a base to create other formats with text-data, for example : to craft a json response for ajax.