asp.net mvc - I cannot call the value of JQuery generated cookie in my controller -


i have created cookie saves last altered state of checkbox. cookie works, have proven passing value of said cookie in alert box. cookie saves state of checkbox on site. need pass value of cookie, or current checkbox value thee controller can alter jquery datatable accordingly. appreciated.

here view script:

    $(function () {          var otable = $('#myissuestable').datatable({             "bprocessing": true,             "bserverside": false,             "bjqueryui": true,              "sajaxsource": '@url.action("getissuesviaajax", "exchange")'          });          $('#activeonly').click(function () {              var activestatus = $('#activeonly:checked').val() ?true:false;              $.cookie("showactiveissues", activestatus, { expires: 365 }, { path: '/' });              alert($.cookie("showactiveissues"))                     //if (navigator.cookieenabled)             //    alert("on");             //else             //    alert("off");             @*$.post("@url.action("getissuesviaajax", "exchange")", { test: activestatus });*@             @*$.ajax({                 url: '@url.action("getissuesviaajax", "exchange")',                 type: 'post',                 //datatype: "json",                 //contenttype: 'application/json',                 //traditional: true,                 data: {test:"testarooskie"}*@         });             otable.fnreloadajax('@url.action("getissuesviaajax", "exchange")');         });          $('#activeonly').ready(function ()         {             //alert($.cookie("showactiveissues"))             var cbcookie = $.cookie("showactiveissues")             if (cbcookie == 1)             {                 //alert("working correctly")                 $('#activeonly').prop('checked', true)             }             else {                 //alert("working incorrectly")                 $('#activeonly').prop('checked', false)             }         });      }); </script>              @html.checkbox("activeonly")             @html.label("active only")</> 

and controller:

public class exchangecontroller : multibase {     itexchangereposity hufdalrepository = new itexchangereposity();     securityreposity hufdalsecurityrepository = new securityreposity();      [httppost]     public actionresult getissuesviaajax(jquerydatatableparammodel param)     {           //httpcookie test = request.cookies["showactiveissues"];         //convert.toboolean(httpcontext.request.cookies["showactiveissues"]);          bool cbvalue = convert.toboolean(request.cookies["showactiveissues"]);//returns default value of "false"          //string cbvalue = convert.tostring(request.cookies["showactiveissues"]);//returns empty value ("").             var issues = hufdalrepository.findallissues(2 , cbvalue);         var result = c in issues          select new[] { c.idtssubmitissue.tostring(), c.subject, c.iduser.tostring(), c.reviewedby, c.statusdescription, c.datesubmitted.toshortdatestring() };              return json(new             {                 secho = param.secho,                 itotalrecords = issues.count(),                 itotaldisplayrecords = issues.count(),                 aadata = result             },             jsonrequestbehavior.allowget);      } 


Comments