我使用了 ajax url 和我从选项框中选择的一个参数月份
$.ajax({
url: baseUri + 'attendancelist/search/attsearch/month/' + month ,
type: 'GET'
...
});
所以我想在我的 attsearchAction() 中调用该参数 所以我这样编码
public function attsearchAction() {
$month = $this->request->get('month'); //current testing framework is phalcon
//$month = $this->_request->getParam('month'); //zend framework is ok by getParam
var_dump($month);exit; //null
}
但它只显示null?如何解决这个问题>>
最佳答案
您将 Phalcon url 参数 attendancelist/search/attsearch/month/[monthValue]
与 GET 参数 (?month=[monthValue]
) 混合在一起。
在 Phalcon 中,您必须设置路由器才能知道 url 的哪一部分是参数。
$router->add(
"attendancelist/search/:action/month/{month}",
array(
"controller" => [your controller],
"action" => 1
)
);
(有关更多信息,请参阅 the Phalcon Router docs)
然后在您的操作中,您必须从调度程序获取参数。
public function attsearchAction() {
$month = $this->dispatch->getParam('month');
var_dump($month);exit;
}
或
public function attsearchAction($month) {
var_dump($month);exit;
}
关于javascript - 无法获取url参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32063103/