如何使用JSON填写表单? [英] How to fill form with JSON?

查看:79
本文介绍了如何使用JSON填写表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将ajax响应作为JSON,需要用它填充表单。如何在jQuery或其他东西中做到这一点?是否比使用 $(json).each()更好?

I get ajax response as JSON and need to fill a form with it. How to do that in jQuery or something else ? Is something better than using $(json).each() ?

JSON:

{ 
  "id" : 12,
  "name": "Jack",
  "description": "Description"
}

填写表格

<form>
  <input type="text" name="id"/>
  <input type="text" name="name"/>
  <input type="text" name="description"/>
</form>


推荐答案

你可能想看看 jQuery Populate插件

虽然这是您拥有的唯一用例,但您也可以手动完成。

Although if this is the only use case you have, you might as well do it manually.

这篇关于如何使用JSON填写表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆