In Symfony 1.4, if I want to send some text to render through an AJAX request, where should I put text
I want to know the best practice.
Example 1
PHP action
class defaultActions extends sfActions
{
public function executeSomething(sfWebRequest $request)
{
$status = 'valid';
if($status == 'valid'){
return $this->renderText('valid');
}
else{
return $this->renderText('invalid');
}
}
}
JS
if (valid)
fun1();
else
fun2();
I would call the controller as normal and then do whatever processing is required in the action.class.php file and then return the text required. So my action.class.php file may well be as simple as :
class defaultActions extends sfActions
{
public function executeSomething(sfWebRequest $request)
{
$sometext = "return value";
return $this->renderText($sometext);
}
}
There are a number of advantages
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.