我想创建 Cakephp 2.0 中最基本的 ajax 链接。
在index.ctp我有
<?php
echo $this->Js->link('myLink', array('controller'=>'technologies', 'action'=>'view'), array('update'=>'#success'));
?>
<div id="success"></div>
在TechnologiesController.php我有
public function view(){
$this->set('msg', 'message');
$this->render('view', 'ajax');
}
在view.ctp我有
<?php echo $msg;?>
它不是在成功 div 中设置视图,而是导航到http://local.cake.com/technologies/view页面以显示消息。
非常感谢任何帮助!