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.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度