we have .serialize() we have .serializeArray() and we have .serializeObject()

When working on one of my apps, I needed to be able to serialize multiple forms and send them off to be processed via ajax call, however not in every situation there are the same number of forms.. they are dynamically created based on certain conditions (say multiple user create submission as an example). so what I needed was a method of serializing all the forms and accessing the data effectivly. I could have easilly done this in php but figured it would be ‘nicer’ if I could do it before sending it to the processing script. so I found this: http://stackoverflow.com/questions/1184624/serialize-form-to-json-with-jquery (I know, gotta love Stack OverFlow right?)

$.fn.serializeObject = 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;
	};