2
我对Kohana/php的世界很陌生,并且在理解如何获得ajax请求的结果时遇到了一些问题。该请求正在通过单击操作进行调用,并且正在调用以下方法。Kohana与AJAX获取请求
function addClickHandlerAjax(marker, l){
google.maps.event.addListener(marker, "click",function(){
console.log(l.facilityId);
removeInfoWindow();
//get content via ajax
$.ajax({
url: 'map/getInfoWindow',
type: 'get',
data: {'facilityID': l.facilityId },
success: function(data, status) {
if(data == "ok") {
console.log('ok');
}
},
error: function(xhr, desc, err) {
console.log(xhr);
console.log("Details: " + desc + "\nError:" + err);
}
}); // end ajax call
});
}
在我的控制器我有一个方法
public function action_getInfoWindow(){
if ($this->request->current()->method() === HTTP_Request::GET) {
$data = array(
'facility' => 'derp',
);
// JSON response
$this->auto_render = false;
$this->request->response = json_encode($data);
}
}
我看到提琴手HTTP请求,并通过正确的facilityID参数。不过,我正在关于如何将所有碎片连接在一起的一些断开。