这是我的js代码。
....
var arrayData = {"projectId": projectId, "stateId":stateId};
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
url: "/bidboldly/projects/editproject/",
data: arrayData,
success : function(response) {
alert(response);
},
error: function(){
alert("error");
}
})
服务器端。
$city = $this->City->find('list',array('conditions' =>array('City.status'=>1, 'City.state_id'=>$this->params['url']['stateId']),'fields'=>array('City.id','City.city'),'order'=>array('City.city ASC')));
echo json_encode($city);
之后在客户端我收到了城市列表+ html。像这样的东西。
..."Young America" [20292]=> string(10) "Zanesville" } <html><head>......
为什么要传输 HTML?