连接在CakePHP 2.2中重置问题 [英] The connection was reset issue in CakePHP 2.2

查看:150
本文介绍了连接在CakePHP 2.2中重置问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是cakephp的新人,当我试图根据国家的动态下拉列表的城市,然后我得到这个错误

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.

我的js代码是

$(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);
  }
  });
});
});

为此,我使用用户控制器上的功能checkcity。这是我的用户控制器文件。

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?

推荐答案

我想,你错过了一个关闭括号,请检查它是不是为你工作
应为:

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'))));

这篇关于连接在CakePHP 2.2中重置问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆