title: How to hook json response to html form via jquery?
body: <p>I'm sure I'm just missing something, but it would be really helpful if someone knows of a way to do this without calling a jquery plugin.</p>
  
  <p>Let's suppose I have a simple html form like the following:</p>
  
  <pre><code>&lt;form id="mainform" action="form.php" method="post"&gt;
      &lt;fieldset&gt;
      &lt;legend&gt;Main Form&lt;/legend&gt;
          &lt;label for="input1"&gt;First Input&lt;/label&gt;
          &lt;input id="input1" name="input1" type="text" /&gt;
          &lt;label for="input2"&gt;First Input&lt;/label&gt;
          &lt;input id="input2" name="input2" type="text" /&gt;
      &lt;/fieldset&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>And I have an ajax function, via jquery, that I want to fill in the above form. Not just the values, but also whether it's read-only, the class of the input, and whether it's disabled.</p>
  
  <p>So the server is going to return all of this to the ajax function in json format, which should look something like:</p>
  
  <pre><code>{"input1":{"value":10},"input2":{"value":100,"readonly":"readonly","class":"noinput"}}
  </code></pre>
  
  <p>Is there a simple way of having jquery go through each top-level object, tie it to the DOM element with the corresponding ID and then set all sub-objects as attributes for that ID?</p>
  
  <p>Sorry if this is a no-brainer. I'm not finding the right way to deal with json in the main jquery pages.</p>