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參數。不過,我正在關於如何將所有碎片連接在一起的一些斷開。