为什么window.location没有重定向到yii框架中的视图页面

时间:2013-05-23 10:09:21

标签: javascript yii

function addCart(){
    //alert('"hello"');
    var cart_id = $('input[name="cart\[\]"]:checked').map(
                              function(n){return this.value;}
                         ).get().join(',');
    //alert(cart_id);
    <?php
    echo Chtml::ajax(array(
                'url'=>array('language/addtocart'),
                'type'=>'post',
                'data'=>'js:{cart_id:cart_id}',
                'success'=>'js:function(){window.location="test"}', 
                ));
    ?>
}    

2 个答案:

答案 0 :(得分:1)

您应该使用window.location.href和正确的网址

 window.location.href="http://localhost/test"

答案 1 :(得分:0)

替换:

'success'=>'js:function(){window.location="test"}',

使用:

'success'=>'js:function(){location.href="test"}',