title: How to fill input fields with an ajax request from MySQL server using PHP?
body: <p>I have an input field that I am trying to fill with an AJAX request to my SQL server using PHP, but it is not working. The console.log spits out the proper array title: ""
  description: "", but it doesnt add the data to the text input field so I can see it. Ive looked at other answers, but they do not suffice. Thanks!<br>
  <strong>HTML</strong></p>
  
  <pre><code>&lt;input type="text" class="inputtext" name="task-title-reg" value=""&gt;
  &lt;textarea class="textbox" name="task-description-reg" rows="4" cols="50" value=""&gt;&lt;/textarea&gt;
  </code></pre>
  
  <p><strong>AJAX REQUEST</strong></p>
  
  <pre><code>                $(".task-listing").click(function() {
                  $.ajax({
                      type: 'POST',
                      url: 'task-info-get.php',
                      dataType: 'json',
                      data: 'pid=' + $(this).attr("id"),
          success: function (response) {
              console.log(response);
              $("task-title-reg").val(response);
              $("task-description-reg").val(response);
          }
                  })
              });
              });
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php
  include 'sqlconnection.php';
  $conn = OpenCon();
  
  $stmt = $conn-&gt;prepare('SELECT title,description FROM tasks WHERE pid='.$_POST['pid']);
  $stmt-&gt;execute();
  $stmt-&gt;bind_result($title,$description);
  while($stmt-&gt;fetch()) {
      $output[]=array(
          'title' =&gt; $title,
          'description' =&gt; $description
  
      );
  }
  $json=json_encode($output);
  echo $json;
  
  $stmt-&gt;close();
  CloseCon($conn);
  ?&gt;
  </code></pre>