ajax-cakephp成功

ajax-cakephp成功,ajax,cakephp-2.0,cakephp-2.1,Ajax,Cakephp 2.0,Cakephp 2.1,如何使用js helper翻译cakephp中的成功 $.ajax({ //(...) success:function (data, textStatus) { $("#city-wrap").html(data); $("#AdCityId").selectbox(); }, }); return false; 我在cakephp中尝试了这一点,但没有成

如何使用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
        ))
    ))
);
$this->Js->get('AdCountryId1')->事件('change',
$this->Js->request(数组)(
“控制器”=>“城市”,
“操作”=>“getByCountry”
),数组(
“更新”=>“#城市包装”,
'success'=>'$(“#AdCityId”)。selectbox()',true,
'方法'=>'获取',
'dataExpression'=>true,
'data'=>this->Js->serializeForm(数组)(
“isForm”=>正确,
“inline”=>true
))
))
);

关于

是否执行实际的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()

我也有同样的问题,我想我找到了一个解决方案,看看它是否适合你

$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
        ))
    ))
);
$this->Js->get('AdCountryId1')->事件('change',
$this->Js->request(数组)(
“控制器”=>“城市”,
“操作”=>“getByCountry”
),数组(
“更新”=>“#城市包装”,
'success'=>'$(“#AdCityId”)。selectbox()',true,
'方法'=>'获取',
'dataExpression'=>true,
“数据”=>$js->serializeForm(数组)(
“isForm”=>正确,
“inline”=>true
))
))
);
试试这个,会有用的