javascript - Angular save vars to laravel session with ajax call dont work -
i want save var session, , when make request ajax dont work. service:
function huntservice( $http ) { this.hunts= { draws : null, hunters: null }; this.savetosession = function( hunts) { var hunts = this.hunts; return $http.post('savetosession', { hunts: hunts }); }; } huntservice.$inject = ['$http']; module.exports = huntservice;
and controller:
class huntcontroller extends \basecontroller { public function saveitems() { session::put('hunts', input::get('hunts')); return response::json(array('saved' => true), 200); } public function destroy($id) { session::forget('hunts'); } public function gethunts() { return session::get('hunts') // dont exits } }
and when im trying test regular request , no ajax working.
the problem here:
var hunts = this.hunts;
here, this.hunts
not exist.
note:
use inspect element/debug tool inspecting request & check whether sending value hunts
attribute in post method or blank. laravel part looks ok.
Comments
Post a Comment