title: Ajax autosave multiple fields
body: <p>I have a page that has fields editable via contenteditable.  I am autosaving the fields via ajax after the user edits the field.  The problem is, I have multiple fields on the same page and when I try to autosave more than one field, either one field won't work or gets overwritten with the same content as the other field.</p>
  
  <p>This is the code that I am using to update the database and it works exactly how I want it to for the "name" field.</p>
  
  <pre><code>$('.editname').keyup(function() {
  delay(function(){
      var name= $('.editname').text();
      $.ajax({
          type:"post",
          url:"update.php",
          data:"name="+name,
          success:function(data){
              console.log('success!');
          }
      });
  }, 500 );
  });
  
  var delay = (function(){
  var timer = 0;
  return function(callback, ms){
      clearTimeout (timer);
      timer = setTimeout(callback, ms);
  };
  })();
  </code></pre>
  
  <p>However if I try to edit it like the following or duplicate it and give it a different name, it will not work properly to update another field along with the first field.</p>
  
  <pre><code>$('.editname').keyup(function() {
  delay(function(){
      var name= $('.editname').text();
      $.ajax({
          type:"post",
          url:"update.php",
          data:"name="+name,
          success:function(data){
              console.log('success!');
          }
      });
  }, 500 );
  });
  
  $('.editsummary').keyup(function() {
  delay(function(){
      var summary= $('.editsummary').text();
      $.ajax({
          type:"post",
          url:"update.php",
          data:"summary="+summary,
          success:function(data){
              console.log('success!');
          }
      });
  }, 500 );
  });
  
  var delay = (function(){
  var timer = 0;
  return function(callback, ms){
      clearTimeout (timer);
      timer = setTimeout(callback, ms);
  };
  })();
  </code></pre>
  
  <p>What am I doing wrong in the above block of code?</p>