Does anyone know the best way to deserialize a form with a json object in jQuery? I see there are a couple plugins out there, but was wondering if anyone with experience in the area know开发者_运维问答s the best one or way to implement without a plugin. Thanks!
Well, it depends a bit on the structure of your JSON input and the structure of your form, but a really straight forward implementation could look as follows: (assuming trusted input)
var form = $('#myForm');
$.each(inputValues, function(name, value) {
form.find('*[name="' + name + '"]').val(value);
});
精彩评论