0
我是新來CakePHP的,當我試圖讓動態下拉狀態的基礎上,城市的名單,然後我得到這個錯誤連接被重置問題CakePHP的2.2
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。這裏是我的用戶控制器文件。
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')));
}
}
現在,當我把這個線在我的控制器文件
$this->set('cities_value',$this->City->find('list', array('conditions' => array('state_id' => $stateid), 'fields' => array('id', 'name')));
然後我得到這個錯誤。有人能告訴我它有什麼問題嗎?
感謝它的工作。 – 2012-07-17 10:45:38