javascript - serialize form to json and store in the cookie -


After I formatting the form back in, I want to store the cookie in json, on the client side. What I'm doing:

Serialization for JSON:

  Function Forms (selector) {var form = {}; $ (Selector) .find (': input [name]: enabled'). Each (function () {var self = $ (this); var name = self.attr ('name'); if (name.indexOf ('text box', 0) == 0} {if (form [name] } {Form} [form]; form] [name] = form [name] + ',' + self.val ();} else {form [name] = self.val ();}}}); return form;}  < 
  $ ('# form1: input'). = FormToJSON ($ ('# form1')); $ .cookie.set ('fo', eba, {json: true}) var a = $ .cookie.get ('fo', true); Alert (A) ; //$.cookie.set('form123 ', {"ksf": "safe", "tt": ""}, {json: true}) // var b = $ cookie.get (' form123 ' , True); //alert(JSON.stringify (b));});   

In Debugger - Aba Jason Obs Q, but alert (A) provides zero.The comment code works, it's json serial, and I'm receiving it from cookies but why does not work for code form ??? taken from jquery.com Cookie plugin

Use this library to parse / parse JSON

Remember that there is a limit of about 4 KB size on cookies,

Comments