【发布时间】:2018-09-13 16:28:35
【问题描述】:
我需要标记一个名为brandId的复选框,
<input type="checkbox" name="lastBrandId" id="lastBrandId" value="1">
当我标记复选框时,我触发另一个 jQuery 带回并填充序列号字段:
<input name="data[Brand][serialNumber]" type="text" id="serialNumber">
如果勾选了复选框,我不想触发下面的 cakephp 2 get 方法:
echo $this->Js->get('#BrandId')->event('change', $this->Js->request(
$ajaxUrl,
array(
'update' => '#form-ajax',
'evalScripts' => true,
'before'=>"$('#loading').show();",
'complete'=>"$('#loading').hide()",
'async' => true,
'method' => 'post',
'data' => $this->Js->serializeForm(array('isForm' => false, 'inline' => true)),
'dataExpression' => true,
)
));
我看不到在这种情况下我可以使用哪个变量。我可以用 JavaScript 代码附上 php 代码吗?
我尝试了包含 cakephp ajax 请求的 php 代码,但没有停止 ajax 请求:
if(!empty($this-request-data['lastBrandId']))
还有其他方法吗?
【问题讨论】:
标签: jquery ajax cakephp-2.3