I am working on an Asp.net page and have fields that aren't organized inside a form. Are there libraries that make it easier to serialize values to JSON elements that aren't in forms to a web method?
Asked
Active
Viewed 155 times
1
-
Well with a simple google search I found many ways, here is one http://stackoverflow.com/questions/1184624/serialize-form-to-json-with-jquery – Aristos Apr 18 '11 at 14:07
-
correct, but those are all assuming the data is in one form. – indigo0086 Apr 18 '11 at 14:24
1 Answers
1
you might search for all inputs on the page or div and serialize them
using jquery :
jQuery.map($('input') , function(n, i){
return {name:n.name,value:n.value};
});
and then convert to json array using for example http://code.google.com/p/jquery-json/ by adding before
$.toJSON( jQuery.map($('input') , function(n, i){
return {name:n.name,value:n.value};
}));

firegnom
- 833
- 7
- 20
-
After some searching this idea seemed to be the eventual outcome, was hoping there was some library already set in place. Guess I can expand it to set element attributes on elements with bind properties and build something around that. Thanks! – indigo0086 Apr 18 '11 at 15:12