ajax cakephp успешно

Как перевести успех в cakephp с помощью помощника js?

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

С уважением


person Elium1984    schedule 02.08.2012    source источник


Ответы (2)


Выполняется ли фактический вызов 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();

person noslone    schedule 07.08.2012

У меня была такая же проблема, я думаю, что нашел одно решение, посмотрим, сработает ли оно для вас.

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

попробуй это сработает

person Rahul Shinde    schedule 01.01.2013