Jquery 如果复选框被标记,CakePhp 2将阻止ajax
我需要标记一个名为brandId的复选框Jquery 如果复选框被标记,CakePhp 2将阻止ajax,jquery,ajax,cakephp-2.3,Jquery,Ajax,Cakephp 2.3,我需要标记一个名为brandId的复选框 <input type="checkbox" name="lastBrandId" id="lastBrandId" value="1"> 我看不出在这种情况下我可以使用哪个变量。我可以用JavaScript代码封装php代码吗 我尝试了包含cakephp ajax请求的php代码,但没有停止ajax请求: if(!empty($this-request-data['lastBrandId'])) 还有其他方法吗?我无法测试它,但也许您可
<input type="checkbox" name="lastBrandId" id="lastBrandId" value="1">
我看不出在这种情况下我可以使用哪个变量。我可以用JavaScript代码封装php代码吗
我尝试了包含cakephp ajax请求的php代码,但没有停止ajax请求:
if(!empty($this-request-data['lastBrandId']))
还有其他方法吗?我无法测试它,但也许您可以使用(格式化以查看逻辑): 其思想是返回false应该停止ajax调用 我个人不再使用JsHelper。外部.js文件更容易调试,并且可以缩小
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,
)
));
if(!empty($this-request-data['lastBrandId']))
'before'=>"
if ($(this).is(':checked')) {
return false;
} else {
$('#loading').show();
return true;
}",