我试图使用Kartik的depdrop,但我一直在第一个菜单上得到一个404文件未找到的错误_form中的一行是
'onchange'=>'$.post("'.Yii::$app->urlManager->createUrl('finaltest/listsubcat?id=').'"+$(this).val(),function(data){$("select#id").html(data);});
']);
在控制台中显示,该邮件正在发送至 http:/paie.locindex.php?r=finaltest%2Flistsubcat%3Fid%3D10。 与404错误如果我把导航器中的地址改为 http:/paie.locindex.php?r=finaltest%2Flistsubcat&id=10。 我得到了第10个选择的期望输出控制器
public function actionListsubcat($id)
{
$countsubcat = Subcat::find()->where(['gfID' => $id])->count();
$subcat = Subcat::find()->where(['gfID' => $id])->orderBy('id')->all();
if ($countsubcat > 0) {
foreach ($subcat as $result) echo "<option value='".$result->id."'>".$result->name."</option>";
} else {
echo "<option>-</option> ";
}
}
Ubuntu Mint 19Apache2服务器
我猜测是apache2的问题,但我没有找到我的paie.loc.conf的内容。
<VirtualHost *:80>
AllowEncodedSlashes On
ServerName XXX.XXX.XXX.XXX/paie.loc
DocumentRoot "/var/www/html/payroll/frontend/web/"
<Directory "/var/www/html/payroll/frontend/web/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php
</Directory>
</VirtualHost>
你正在使用"..."。createUrl()
的方式不对--第一个参数应该是路由,所以将 ?id=
是不正确的。如果你想用param建立URL,你应该使用数组。你可能需要试试这样的方法。
'onchange' => '$.post("'
. Yii::$app->urlManager->createUrl(['finaltest/listsubcat', 'id' => ''])
. '" + $(this).val(), function(data){$("select#id").html(data);});