0

jsヘルパーを使用して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
        ))
    ))
);

よろしく

4

2 に答える 2

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

于 2012-08-07T14:06:54.040 に答える
0

私は同じ問題を抱えていました.1つの解決策を見つけたと思います.

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

これを試してみてください

于 2013-01-01T09:36:21.170 に答える