开发者

Need a jQuery Form Deserializer

开发者 https://www.devze.com 2023-01-27 03:28 出处:网络
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开发者_运维问答

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);
});
0

精彩评论

暂无评论...
验证码 换一张
取 消