You can serialize form fields into JSON and stringify the result.
/**
* Serialize form fields into JSON
**/
(function($){
$.fn.serializeJSON = function(){
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
}
})(jQuery);
So you'll have one string with all fields, put it into an hidden field and submit the form:
myString= JSON.stringify($('#myForm').serializeJSON());
$("#myForm #myString").val(myString);
$("#myForm").attr("action", YOUR_URL);
$("#myForm").submit();
This is supposed to be the form:
<form id="myForm" method="POST">
<input type="hidden" id="myString" />
</form>