阿贾克斯cakephp成功

How do I translate succes in cakephp with js helper ?

$.ajax({
//(...)
success:function (data, textStatus) {
                        $("#city-wrap").html(data);
                        $("#AdCityId").selectbox();
                    },
});
return false; 

I tried This in cakephp no success :

 $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
        ))
    ))
);

Regards

Does the actual ajax call get executed?

If yes; try this to see if the success callback is really called.

$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
            ))
        )
    )
);

If you will see the Success! message, there is probably something wrong with $('#AdCityId').selectbox();

I had same problem I think I found one solution see if it work for you

$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
        ))
    ))
);

try this it will work