Yii - CJui自动完成没有结果显示,即使网络请求的状态为200


Yii - CJuiAutoComplete no results displaying even though network request has status 200

我正在尝试实现 CJuiAutoComplete 小部件,但无法显示任何结果。 这是我的代码:

HighSchoolsController.php

public function actionSearchHighSchools() {
$criteria=new CDbCriteria;
$model = new HighSchools;
$criteria->compare('SchoolName',$model->SchoolName,true);
$criteria->compare('City',$model->City,true);
$criteria->compare('State',$model->State,true);
$dataProvider = new CActiveDataProvider($model, array('criteria'=>$criteria));
$highSchools = $dataProvider->getData();
$return_arr = array();
foreach($highSchools as $highSchool){
  $return_arr[] = array(
    'value' => $highSchool->SchoolName,
    'label' => $highSchool->SchoolName,
    'id' => $highSchool->id,
  );
}
return CJSON::encode($return_arr);

}

_buildEducation.php (view file)

<?php
  $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
    'name'=>'highschool',
    'sourceUrl'=>$this->createUrl('highSchools/searchHighSchools'),
    'options'=>array(
      'minLength'=>'2',
    )
  ));
?>

现在,在我的控制器函数中,如果我 var 转储CJSON::encode($return_arr)而不是返回它,我会得到以下输出:

string(688) "[{"value":"ALBERT P BREWER HIGH SCH","label":"ALBERT P BREWER HIGH SCH","id":"1"},{"value":"ALBERTVILLE HIGH SCH","label":"ALBERTVILLE HIGH SCH","id":"2"},{"value":"ALICEVILLE HIGH SCH","label":"ALICEVILLE HIGH SCH","id":"3"},{"value":"ALMA BRYANT HIGH SCH","label":"ALMA BRYANT HIGH SCH","id":"4"},{"value":"ANDALUSIA HIGH SCH","label":"ANDALUSIA HIGH SCH","id":"5"},{"value":"ANNISTON HIGH SCH","label":"ANNISTON HIGH SCH","id":"6"},{"value":"ARAB HIGH SCH","label":"ARAB HIGH SCH","id":"7"},{"value":"ASHVILLE HIGH SCH","label":"ASHVILLE HIGH SCH","id":"8"},{"value":"ATHENS HIGH SCH","label":"ATHENS HIGH SCH","id":"9"},{"value":"AUBURN HIGH SCH","label":"AUBURN HIGH SCH","id":"10"}]"

所以我知道小部件正在发送正确的数据,就像我在标题中所说的那样,网络请求返回正常,状态为 200,但由于某种原因结果不会显示。 谁能看到我做错了什么?我从 Yii 文档和论坛中提取代码并根据我的需求量身定制,但代码基本上与说它适合他们的人相同

通了...需要回显 JSON 结果而不是返回它们