i'm working cakephp web application, have created small ajax function in default ctp file. setup file want send value data controller function, in chrome browser network showing ajax posting desire url in controller post value didn't show when try echo $_post ['selectedlocation']??
ajax default file
var displaylocationname = $('#listinglocation option:selected').val(); $.ajax({ type: "post", url: '/listings/home', data: {selectedlocation:displaylocationname }, datatype:"text", success: function(result) { } }); listing controller function
function home() { if(!isset($this->params['requested']) || $this->params['requested'] != true) { $this->actionid = 'home'; } $this->viewfile = null; if($this->params['isajax'] && isset($_post['selectedlocation'])) { echo "erreerreer"; echo $selectloc= $_post['selectedlocation']; $this->set('selectloc',$selectloc); } } how display ajax post value in default testing purposes that, make sure me ajax posting proper values controller
you need use logging files read post data. write data error log , can view there.
function home() { if(!isset($this->params['requested']) || $this->params['requested'] != true) { $this->actionid = 'home'; } $this->viewfile = null; if($this->params['isajax'] && isset($_post['selectedlocation'])) { echo "erreerreer"; cakelog::write('error', $this->request->data('selectedlocation)); echo $selectloc= $_post['selectedlocation']; $this->set('selectloc',$selectloc); } }
Comments
Post a Comment