title: serialize form to json and store in the cookie
body: <p>i want to store form on clientside, in json in cookie, after that deserialize it back to form.
  what i'm doing:</p>
  
  <p>serialization to JSON:  </p>
  
  <pre><code>function formToJSON(selector) {
      var form = {};
      $(selector).find(':input[name]:enabled').each(function () {
          var self = $(this);
          var name = self.attr('name');
  
          if (name.indexOf('TextBox', 0) == 0) {
              if (form[name]) {
                  form[name] = form[name] + ',' + self.val();
              }
              else {
                  form[name] = self.val();
              }
          }
      });
  
      return form;
  }
  </code></pre>
  
  <p>then on form change, i'm trying to save form to cookie:</p>
  
  <pre><code> $('#form1 :input').change(function () {
  
      var eba = formToJSON($('#form1'));
  
      $.cookie.set('fo', eba, {json:true});
      var a = $.cookie.get('fo',true);
      alert(a);
  
  
      //$.cookie.set('form123', { "ksf": "saf", "tt": "" }, { json: true });
      //var b = $.cookie.get('form123', true);
      //alert(JSON.stringify(b));
  });
  </code></pre>
  
  <p>in debugger - eba is json object, but alert(a) gives null.
  commented code works, this json serialized, and i'm gettin it from cookies.
  but why code doesnt work for form???
  cookie plugin taken from jquery.com</p>