dongxing6802 2018-03-22 13:11
浏览 42
已采纳

Yii2 Kartik依赖下拉列表 - 标头已发送异常

In Yii2 I have integrated Kartik Depdrop widget. When I am using the Indian state and city in the table, it is working fine. but once I update the same table with US state and city,

the dependent field is not filled up and in firebug response is shown correctly but along with error - headers already sent exception like:

An Error occurred while handling another error: yii\web\HeadersAlreadySentException: Headers already sent in /var/www/clients/client2/web206/web/controllers/UserController.php on line 159. in /var/www/clients/client2/web206/web/vendor/yiisoft/yii2/web/Response.php:366

The relevant code is like this:

public function actionSubcat() {
$out = [];
if (isset($_POST['depdrop_parents'])) {
$parents = $_POST['depdrop_parents'];
if ($parents != null) {
$cat_id = $parents[0];
$out = UserProfile::GetCity($cat_id);
// the getSubCatList function will query the database based on the
// cat_id and return an array like below:
// [
// ['id'=>'<sub-cat-id-1>', 'name'=>'<sub-cat-name1>'],
// ['id'=>'<sub-cat_id_2>', 'name'=>'<sub-cat-name2>']
// ]
echo Json::encode(['output'=>$out,'selected'=>'']); // this is line 159
    return;
 }
         }
         echo Json::encode(['output'=>'','selected'=>'']);

    }

So I am not able to make, what is causing the issue and how I can fix it.

only difference to me it looks like is the number of database entries are more compared to Indian state and city.

  • 写回答

1条回答 默认 最新

  • doq13207 2018-03-22 17:11
    关注
    echo Json::encode(['output'=>$out,'selected'=>'']); // this is line 159
    return;
    

    ALTER FOR

    return Json::encode(['output'=>$out,'selected'=>'']);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!