Jquery Symfony:用AJAX加载组件时出现问题

Jquery Symfony:用AJAX加载组件时出现问题,jquery,ajax,symfony1,components,Jquery,Ajax,Symfony1,Components,我尝试在Symfony上下文中通过AJAX加载组件 我已在我的视图中创建了我的链接: <?php echo jq_link_to_remote('Compétences', array( 'update' => 'right_column', 'url' => 'personnage/loadCompetences', 'position' => 'top', )); ?> 和组件(co

我尝试在Symfony上下文中通过AJAX加载组件

我已在我的视图中创建了我的链接:

<?php
    echo jq_link_to_remote('Compétences', array(
        'update'   => 'right_column',
        'url'      => 'personnage/loadCompetences',
        'position' => 'top',
    ));
?>
和组件(controller+view
\u competency.php

公共功能执行能力(sfWebRequest$request){
$personnage=$this->getUser()->getGuardUser()->personnage;
$this->touch=$personnage->getCom_touch();
$this->ecriture=$personnage->getCom_ecriture();
$this->armes=$personnage->getCom_armes();
$this->bouclier=$personnage->getCom_bouclier();
$this->policitie=$personnage->getCom_policitie();
$this->commandement=$personnage->getCom_commandement();
$this->冥想=$personnage->getCom_冥想();
$this->embuscade=$personnage->getCom_embuscade();
$this->herboristerie=$personnage->getCom_herboristerie();
$this->espionnage=$personnage->getCom_espionnage();
}
  • 演讲 .png“/>
  • ...
但如果我没有定义loadCompetinceSuccess.php(包括该组件),我就无法加载该组件


有没有一种方法可以在不创建xxxSuccess.php视图的情况下加载组件?

您的操作代码中缺少一个
返回:

return $this->renderComponent("personnage", "competences");
除非您返回某些内容,否则symfony将假定“成功”,这就是它在默认情况下查找actionnameSuccess.php的原因

另外:不要像那样硬编码图像路径,而是查看
image\u路径
image\u标签
帮助程序

public function executeCompetences(sfWebRequest $request){
        $personnage = $this->getUser()->getGuardUser()->Personnage;
        
        $this->lecture = $personnage->getCom_lecture();
        $this->ecriture = $personnage->getCom_ecriture();
        $this->armes = $personnage->getCom_armes();
        $this->bouclier = $personnage->getCom_bouclier();
        $this->diplomatie = $personnage->getCom_diplomatie();
        $this->commandement = $personnage->getCom_commandement();
        $this->meditation = $personnage->getCom_meditation();
        $this->embuscade = $personnage->getCom_embuscade();
        $this->herboristerie = $personnage->getCom_herboristerie();
        $this->espionnage = $personnage->getCom_espionnage();
}


<div id="subpanel">
    <ul id="competences">
        <li class="competence">
            <span>Lecture</span>
            <img alt="" src="/medieval-ages-v2/web/images/competences/competences_<?php echo $lecture ?>.png" />
        </li>
    ...
    </ul>
</div>
return $this->renderComponent("personnage", "competences");