title: How to trigger Ajax call based on text field?
body: <p>I'm trying to trigger my Ajax function when any of the text fields are changed.. I'm totally new to Ajax so I don't know how or if this is possible.. Any help will be very appreciated! </p>
  
  <p><strong>Html</strong></p>
  
  <pre><code>&lt;form&gt;
      &lt;a&gt;Enter Item ID 1:&lt;/a&gt; 
      &lt;input id="target1" type="text" name="itemID" required /&gt;   
      &lt;br&gt;
      &lt;a&gt;Enter Item ID 2:&lt;/a&gt; 
      &lt;input id="target2" type="text" name="itemID2"/&gt;    
      &lt;div class="result"&gt;&lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Script</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function(){
      $('#target').change(function() {
          $.ajax({
              url: 'shelfid.php',
              type: 'POST',
              dataType: 'json',
              data:{ 
                  itemID: $(this).val() 
              },
              success:function(data) {
                  $(".result").text(data);    
              }
          });
      });
  });
  &lt;/script&gt;
  </code></pre>