如何使用js helper翻译cakephp中的成功?
$.ajax({
//(...)
success:function (data, textStatus) {
$("#city-wrap").html(data);
$("#AdCityId").selectbox();
},
});
return false;
我在cakephp中试过这个没有成功:
$this->Js->get('#AdCountryId1')->event('change',
$this->Js->request(array(
'controller'=>'cities',
'action'=>'getByCountry'
), array(
'update'=>'#city-wrap',
'success'=> '$("#AdCityId").selectbox()';, <= here is what I need !
'async' => true,
'method' => 'get',
'dataExpression'=>true,
'data'=> $this->Js->serializeForm(array(
'isForm' => true,
'inline' => true
))
))
);
此致
答案 0 :(得分:0)
是否执行了实际的ajax调用?
如果是;试试看是否真的调用了成功回调。
$this->Js->get('#AdCountryId1')->event('change',
$this->Js->request(
array(
'controller'=>'cities',
'action'=>'getByCountry'
),
array(
'update'=>'#city-wrap',
'success'=> "alert('Success!'); $('#AdCityId').selectbox();",
'async' => true,
'method' => 'get',
'dataExpression'=>true,
'data'=> $this->Js->serializeForm(array(
'isForm' => true,
'inline' => true
))
)
)
);
如果你会看到成功!消息,$('#AdCityId').selectbox();
答案 1 :(得分:0)
我有同样的问题,我想我找到了一个解决方案,看看它是否适合你
$this->Js->get('#AdCountryId1')->event('change',
$this->Js->request(array(
'controller'=>'cities',
'action'=>'getByCountry'
), array(
'update'=>'#city-wrap',
'success'=> '$("#AdCityId").selectbox()';, <= here is what I need !
'async' => true,
'method' => 'get',
'dataExpression'=>true,
'data'=> $js->serializeForm(array(
'isForm' => true,
'inline' => true
))
))
);
试试这个会起作用