title: How to append json array to value attribute
body: <p>There is a search box in my view. </p>
  
  <p><img src="https://i.stack.imgur.com/VOOUO.png" alt="img"></p>
  
  <p>When i search product on here it will retrieve(single) product using ajax</p>
  
  <p>my ajax code is</p>
  
  <pre><code>&lt;script&gt;
  $(function() {
    $("#update_prod").click(function(event) {
      event.preventDefault();
      var head = $("#update_product").val();
      $.ajax({
        dataType: 'json',
        type: "post",
        url: "&lt;?php echo base_url(); ?&gt;index.php/admin/update_product",
        data: {
          product: head
        },
        success: function(data) {
  
        }
      });
    });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>so in Controller</p>
  
  <pre><code>public function update_product() {
    $product = $_POST['product'];
    $query = $this - &gt; db - &gt; query("Select  * From product Where  title Like '%$product%' and online=1");
    $result = $query - &gt; result_array();
    echo json_encode($result);
  }
  </code></pre>
  
  <p>and im reviving data in my console</p>
  
  <pre><code>[{
    "id": "99",
    "brand_id": "8",
    "category_id": "1",
    "mark": "0",
    "title": "Corsair Memory - 1GB 533MHz DDR2 Desktop Memory(VS1GB533D2 ",
    " model ": " Corsair Memory - 1 GB ",
    " sub ": " Corsair Memory - 1 GB DDR2 Desktop Memory ",
    "price": "3250",
    "price_update": "1",
    "description": "",
    "overview": "1",
    "offer": "0",
    "stock": "0",
    "online": "1",
    "other": "0",
    "video": "0",
    "valid": "Price Valid 2 Weeks Only"
  }]
  </code></pre>
  
  <blockquote>
    <p>My <strong>Question is</strong> how to retrieve data and <strong>append to the value</strong> of below input tags</p>
  </blockquote>
  
  <pre><code>&lt;input type="text" class="form-control" name="new_title" value=""&gt;//title should come here
  &lt;input type="number" class="form-control" name="new_price" value=""&gt;//price should come here
  &lt;select class="form-control" name="new_price_update"&gt;//if price_update==1 then Yes should be select, else No will be select
    &lt;option value="1"&gt;Yes&lt;/option&gt;
    &lt;option value="0"&gt;No&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <blockquote>
    <p>Note : I check all stack Question but unable to find better solution for this</p>
  </blockquote>