I have used ajax url with one parameter month which i selected from option box
$.ajax({
url: baseUri + 'attendancelist/search/attsearch/month/' + month ,
type: 'GET'
...
});
So i want to call that parameter in my attsearchAction() So i code like this
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
}
But it only show null? How to fix that>>
If you want to pass parameter with url than you should use ?
to pass parameter
url: baseUri + 'attendancelist/search/attsearch/?month=' + month
Alternately, as you are using ajax, so you can send the data using ajax.
$.ajax({
url: baseUri + 'attendancelist/search/attsearch/',
type: 'GET',
data: {month: month},
...
});
You are mixing Phalcon url parameters attendancelist/search/attsearch/month/[monthValue]
with GET parameters (?month=[monthValue]
).
In Phalcon you would have to set up your router to know which part of the url is the parameter.
$router->add(
"attendancelist/search/:action/month/{month}",
array(
"controller" => [your controller],
"action" => 1
)
);
(See the Phalcon Router docs for more information)
Then in your action you would have to get the parameters from the dispatcher.
public function attsearchAction() {
$month = $this->dispatch->getParam('month');
var_dump($month);exit;
}
or
public function attsearchAction($month) {
var_dump($month);exit;
}