Here is what I use for this situation as a module (in my formhelper.js):
define(function(){
FormHelper = {};
FormHelper.parseForm = function($form){
var serialized = $form.serializeArray();
var s = '';
var data = {};
for(s in serialized){
data[serialized[s]['name']] = serialized[s]['value']
}
return JSON.stringify(data);
}
return FormHelper;
});
It kind of sucks that I can't seem to find another way to do what I want to do.
This does return this JSON for me:
{"first_name":"John","last_name":"Smith","age":"30"}