Cakephp - ajax请求和操作'编辑'不能同时工作

cakephp - ajax request and action 'edit' does not work in simultaneous

本文关键字:不能 工作 编辑 求和 操作 Cakephp ajax 请求      更新时间:2023-09-26

我使用ajax ($this->Js->get)来选择任何下拉列表的元素,然后填充其他下拉列表。但是,我有这些下拉列表在一个表单->create('User')。

所以,如果我使用form->create(false)我的动作'edit'不起作用…另一方面,如果我使用form->create('User')我的'ajax'不起作用。

<?php echo $this->Form->create('User', array('action' => 'edit')); ?>
<table>
        <tr>
            <th>PROJECT</th>
            <th>VERSION</th>
        </tr>
          <tr>
            <td>   <?php
                 echo $this->Form->select('projects', array($projects), array('multiple' => false,
                    'class' => 'span2',
                    'id' => 'projectsTest'));
                ?>
            </td>     
            <td> 
                <?php
                echo $this->Form->select('projectversions', array($projectversions), array('multiple' => false, 'class' => 'span2',
                    'id' => 'projectversionsTest'));
                ?>
            </td>
        </tr>
</table> 
<?php echo $this->Form->button('ALTERAR', array('type' => 'submit', 'class' => "btn btn-info pull-right")); ?>

<?php
$this->Js->get('#projectsTest')->event('change', $this->Js->request(array(
            'controller' => 'ProjectVersions',
            'action' => 'getVersionsofProject'
                ), array(
            'update' => '#projectversionsTest',
            'async' => true,
            'method' => 'post',
            'dataExpression' => true,
            'data' => $this->Js->serializeForm(array(
                'isForm' => true,
                'inline' => true
            ))
)));

echo $this->Form->end();
?>

如何解决这个问题?

提前感谢:)

这样不行吗?

echo $this->Form->create(null, array(
    'url' => array('controller' => 'users', 'action' => 'edit')
));