cakephp pass ajax中的下拉值 [英] cakephp pass dropdown value in ajax

查看:96
本文介绍了cakephp pass ajax中的下拉值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设法在cakephp中获取ajax函数,当点击下拉菜单来填充另一个下拉列表时,会调用该函数。我不能得到的一个领域是传递的第一个下拉列表的id值,所以我可以做一个查找。

I have managed to get the ajax function in cakephp which calls when a dropdown is clicked to populate another dropdown. The one area I cannot get is passing in the id value of the first dropdown so I can do a find.

我希望通过公司id,所以我可以得到相关员工。

I wish to pass in the company id so I can get the related employees.

感谢。

查看:

<?php
$this->Js->get('#MonthlyReturnCompanyId')->event('change',
$this->Js->request(
    array(
        'controller'=>'MonthlyReturns',
        'action'=>'getemployees',
    ),
    array(
        'update'=>'#test',
        'async' => true,
        'method' => 'post',
        'dataExpression'=>true,
        'data'=> $this->Js->serializeForm(array(
            'isForm' => false,
            'inline' => true
        ))
    )
)
);
?>



        echo $this->Form->input('company_id' , array('empty' => true));


推荐答案

in redirects
ie:

simply pass the company_id at the action request same as done in redirects i.e. :

 $this->Js->request(
array(
    'controller'=>'MonthlyReturns',
    'action'=>'getemployees',$company_id),
array(
    'update'=>'#test',
    'async' => true,
    'method' => 'post',
    'dataExpression'=>true,
    'data'=> $this->Js->serializeForm(array(
        'isForm' => false,
        'inline' => true
    ))
)
)
);

这篇关于cakephp pass ajax中的下拉值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆