Use jQuery to replace form params with a JSON object on submit
How w开发者_Go百科ould you code the function replaceFormParamsWithJsonObject(jsonObject)?
$('#myForm').submit(replaceFormParamsWithJsonObject(jsonObject));
Not sure exactly what you're after but something like this?
$.each(jsonObject, function(key, value)
{
$(this).find('input:[name=' + key + ']').val(value);
});
This will update the form inputs with names corresponding to the object's keys.
精彩评论