Hi,
Relatively new to both jQuery and JSON here, so bear with me.
What I am trying to do is $.post() some JSON to a PHP script.
serialize() works great for generating a GET string, but is there
nothing out-of-the-box for creating a JSON string? I realize that I
could grab the JSON library and use .stringify(), and of course the
following works fine:
formVals = new Array();
$(':input').each(function() {
formVals.push('"' + $(this).attr('name') + '":"' + $(this).val() +
'"');
});
return '{' + formVals.join() + '}';
I'm just trying to understand the more general issue and philosophy.
What's the utility of the JSON object returned by serializeArray? And
what is the most efficient way to create a JSON string from a form
without resorting to any plugins or additional scripts?
Best,
Donald