[英]I am getting Error 400 invalid request
我是php的新手,正在使用yii ....我正在嘗試渲染我在控制器中聲明的頁面,該頁面將顯示特定的用戶信息,而渲染視圖頁面時出現錯誤400無效請求。有人可以幫助嗎請注意:我已經在控制器的規則中聲明了動作函數。
我的控制器代碼:
public function actionReview($id)
{
$model = new CvUpload;
$this->render('review', array('model'=>$model,'id' => $id,));
}
我的查看代碼:
<?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>
我解決了問題....錯誤出在數據提供者的查看頁面代碼中。我正在調用已登錄的用戶ID,而應該調用特定ID的ID。 視圖頁面中的代碼已更改:
'dataProvider'=>$model->searchByUserId(Yii::app()->user->getId()),
將代碼替換為:
'dataProvider'=>$model->search(),
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.