doufang6268 2015-08-20 09:13
浏览 79

我收到错误400无效请求

I am new at php and using yii....I am trying to render a page which i declare in my controller which will show a specific user information,while rendering the view page i am getting ERROR 400 invalid request.can anyone please help me out with my error.Note that: I have declare my action function in rules in the controller.

My controller code:

    public function actionReview($id)
{
    $model = new CvUpload;
    $this->render('review', array('model'=>$model,'id' => $id,));
}

My View code:

    <?php
$this->menu=array(
    array('label'=>'List CvUpload', 'url'=>array('index')),
    array('label'=>'Create CvUpload', 'url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
    $('.search-form').toggle();
    return false;
});
$('.search-form form').submit(function(){
    $('#cv-upload-grid').yiiGridView('update', {
        data: $(this).serialize()
    });
    return false;
});
");
?>

<h2 align="center">Manage CV Upload</h2>

    <?php }
        $this->widget('booster.widgets.TbGridView', array(
        'id'=>'cv-upload-grid',
        'type' => 'striped bordered condensed',
        'dataProvider'=>$model->searchByUserId(Yii::app()->user->getId()),
        'columns'=>array(
            'cv_id',
                array('header'=>'Employee Name',
                        'value'=>'$data->user->user_id'),
        array('name'=>'job_title_id',
                    'type'=>'raw',

                    'value'=>'CHtml::Link($data->jobTitle->name,array("JobTitle/view","id"=>$data->jobTitle->id))'),    

            'cv_type',
            'version_id',
            'upload_date',
            'update_date',
            'file_name',
            'next_review_date',
            'review_status',
            'is_current',
            array(
                'header'=>'Actions',

                'class'=>'CButtonColumn',
                'template'=>'{view}{update}{down}',
                'buttons'=>array(
                   'down' => array(
                     'label'=>'Download',
              'imageUrl'=>Yii::app()->request->baseUrl.'/assets/d01d65b0/listview/down.gif',
                         'url'=>'$this->grid->controller->createUrl("download", array("new_url"=>$data->file_name))',
              ),
              ),


            ),),)
            );



 ?>





<div class="modal"></div>

<div id="showdata"></div>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-migrate/1.2.1/jquery-migrate.min.js"></script>

<script type="text/javascript">

    $body = $("body");
    $(document).on(
    {
        ajaxStart: function()
        {
        $body.addClass("loading");
        },
        ajaxStop: function()
        {
        $body.removeClass("loading");
    }
    });

    $(document).ready(function(e) 
    {

            $('input#view').live('click', function(e)
        {
            var dataId = $(this).parent().prev().prev().prev().prev().prev().prev().prev().prev().prev().text();//alert(dataId);
            $.ajax({
                type: 'POST',
                data: {
                    id:dataId,
                },
                url: "<?php echo $this->createUrl("CvUpload/viewAjax"); ?>",
                success: function(data, textStatus, jqXHR,html) {
                  console.log(data);
                  console.log(textStatus);
                  console.log(jqXHR);
                  if(textStatus=='success'){
                    $("#showdata").children().remove();
                    $("#showdata").append(data);
                    $('html, body').animate({
                        scrollTop: $("#showdata").offset().top
                        }, 1000);
                  }
                },
                error: function(textStatus, errorThrown) {
                  console.log(textStatus);
                  console.log(errorThrown);
                }
            });
            return false;
        });
         $('#cancel').live('click', function(e)
        {
            $("#showdata").children().remove();
        });

    });


</script>
  • 写回答

1条回答 默认 最新

  • dongxun1142 2015-08-23 13:02
    关注

    I solved the problem....the error was in the view page code in data provider.I was calling the logged in user id,rather i should call the id of the specific id. Changed code in view page:

     'dataProvider'=>$model->searchByUserId(Yii::app()->user->getId()),
    

    Replace the code to :

    'dataProvider'=>$model->search(),
    
    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)