The connection was reset issue in CakePHP 2.2

只谈情不闲聊 提交于 2019-12-24 18:18:45

问题


I am new to cakephp when i am trying to make dynamic drop down list of cities on the basis of states then i am getting this error

The connection was reset.

My js code is

$(document).ready(function(){
$('#UserState').change(function(){
  var stateid=$(this).val();
  $.ajax({
  type: "POST",
  url: "checkcity",
  data:'stateid='+stateid+'&part=checkcity',
  success: function(data) {
  $("#city_div").html(data);
  }
  });
});
});

And for this i am using function checkcity on User controller. here is my user controller file.

 class UsersController extends AppController {
 public $uses=array('User', 'City','State');
 function index(){

  }
  public function add() {

    $this->set('states_options', $this->State->find('list', array('fields' =>array('id','name') )));
$this->set('cities_options', array());
    if ($this->request->is('post')) {
        $this->User->create();
        if ($this->User->save($this->request->data)) {
            $this->Session->setFlash(__('The user has been saved'));
            $this->redirect(array('action' => 'index'));
        } else {
            $this->Session->setFlash(__('The user could not be saved. Please, try again.'));
        }
    }
}

public function checkcity(){
$this->layout=false;
$stateid=$this->request->data['stateid'];
$this->set('cities_value',$this->City->find('list', array('conditions' =>    array('state_id' => $stateid), 'fields' => array('id', 'name')));
}
}  

Now when i put this line in my controller file

       $this->set('cities_value',$this->City->find('list', array('conditions' =>    array('state_id' => $stateid), 'fields' => array('id', 'name')));

then i get this error. Can anybody tell me what is the issue in it?


回答1:


What I think, you missed one closing bracket. Kindly check if it is not working for you. It should be:

$this->set('cities_value',$this->City->find('list', array('conditions' =>    array('state_id' => $stateid), 'fields' => array('id', 'name'))));


来源:https://stackoverflow.com/questions/11520404/the-connection-was-reset-issue-in-cakephp-2-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!