出于某种原因,如果我将表单元素更改为隐藏,我的 ajax 表单将不起作用。如果我将它们更改为输入,它会如何工作。为什么会这样?
这是视图
<div id="price">
<?php
$this->Js->get('#phonepricearea');
echo $this->Form->create('offer', array('url' => '/PhoneKarma/PhoneQueries/ajaxOffer', 'class' => 'custom'));
echo $this->Form->hidden('phoneCapacity',array('value'=>''));
echo $this->Form->hidden('phoneCondition',array('value'=>''));
echo $this->Form->hidden('carrier',array('value'=>''));
echo $this->Js->submit('Check', array('class' => 'button expand',
'title' => 'Check',
'url' => array(
'action' => 'ajaxOffer'
),
'update' => '#price'
));
echo $this->Form->end();
?></div>
控制器
public function ajaxOffer($capacity=null, $condition = null , $carrier = null) {
if (!empty($this->data) && $this->request->is('ajax')) {
//do stuff this doesn't effect the code..
$this->render('ajaxOffer', 'ajax');
} else {
$this->set('offer', "0");
}
}
Javascript更改值
$('#offerPhoneCapacity').val(id);