1
我有一個Yii2先進的應用程序與Dynagrid並與一列編輯(http://demos.krajee.com/editable)
我寫的本地PC和編輯工作正常
上 我試圖用編輯控件更新字段的值時,將文件複製到我的主機上,現在我得到內部服務器錯誤
調查表明我的地方,錯誤發生yii2編輯內部服務器錯誤只(類警予傭工 JSON未找到)
POST http://.../backend/web/index.php?r=trackdata%2Findex 500 (Internal Server Error)
send @ jquery.js:9177
...
通過點擊此jqery .js我看到:
xhr.send(options.hasContent && options.data || null); with the red error flag
當引入的console.log(XHR);在xhr.send指令之前,我看到:
response:"<pre>PHP Fatal Error 'yii\base\ErrorException' with message 'Class 'yii\helpers\json' not found' ↵↵in .../backend/controllers/TrackdataController.php:63↵↵Stack trace:↵#0 [internal function]: yii\base\ErrorHandler->handleFatalError()↵#1 {main}</pre>"
responseText的
所以原因是:類警予\傭工\ JSON沒有發現 但在我控制我用警予JSON助手,你可以在看我的控制器:
use yii\helpers\json;
...
if (Yii::$app->request->post('hasEditable'))
{
$trackId = Yii::$app->request->post('editableKey');
$model = Trackdata::findOne($trackId);
$out = Json::encode(['output'=>'', 'message'=>'']);
$post = [];
$posted = current($_POST['Trackdata']);
$post['Trackdata'] = $posted;
if ($model->load($post))
{
$model->save();
$output = '';
$out = Json::encode(['output'=>$output, 'message'=>'']);
}
echo $out;
return;
...
這是視圖:
<?= DynaGrid::widget([
'columns' => [
...
[
'class' => 'kartik\grid\EditableColumn',
'attribute'=>'vu',
'editableOptions'=> function ($model, $key, $index) {
return [
'displayValueConfig' => [1 => 'Oui', 0 => 'Non'],
'displayValue' => [1 => 'Oui', 0 => 'Non'],
'data' => [1 => 'Oui', 0 => 'Non'],
'value' => 0,
'asPopover' => true,
'header' => 'Vu ',
'inputType' => Editable::INPUT_DROPDOWN_LIST,
];
}
],
...
I C注意看看爲什麼我只在主機上而不是在本地PC上收到此錯誤。 任何幫助將會很好!