dongyi6845 2013-09-17 10:00
浏览 45

ZEND框架和JQuery / AJAX

I am new to zend framework and as well as ajax. I want a specific action in my application.

Let say I have an action and its corresponding view. In that view I have multiple things like chart plotting, table making and other HTML things.

I want to only update the chart on drop drown change event without loading whole page again.

How can do this. Help me in this regard.

I searched a lot but can't find any thing useful.

IndexContrller

public homeAction(){

if($num==0){
//Chart Data Here
}
else if(num==1){
//Table Data Here
}
}

In short I want to update an Action portion using Ajax in ZEND Framework.

  • 写回答

1条回答 默认 最新

  • duanlongling5308 2013-09-17 10:36
    关注

    how I have implemented Ajax submission using jQuery in Zend Framework. You have to build your form like the following.

    $form->setAttrib('id','div_form');
    $form->addElement('submit', 'submit', array(
        'label' => 'Ajax Submit',
        'onclick' => "$('#div_form').load('" . "/index/home" . "', $('#div_form').serializeArray() ); return false;"
    ));
    

    Add the submit like the one shown above.

    return false; cancels actual submission of form.

    In your IndexController.php,

    public function homeAction() {
        $this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(TRUE);
        //Get your form data from the params
        Zend_Debug::dump($this->_getAllParams());
        //Process data using your model and return appropriate messages.
        echo "Your form is submitted"; // here you can render your element for display graph in view
    }
    

    Try the above and let me know if you have any issues.

    hope this will sure help you.

    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记