title: getting value from same class with AJAX/jQuery
body: <p>How Can I get value from same class?
  It just get the value from one class (the first)</p>
  
  <p>look the code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>$(document).ready(function() {
      $('.getdata').click(function() {
          var name  = $('.name').val();
          var userid = $('.userid').val();
          console.log(name);
          console.log(userid);
          var dataString = 'userid=' + name + '&amp;name=' + name;
          $.ajax({
              type: "POST",
              url: "ajax.php",
              data: dataString,
              dataType: "json",
              success: function(data) {
              }
          }); 
          return false;
      });
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>this is in a loop</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form action='' method='POST'&gt;
      &lt;input type='hidden' class='name' value='".$row["name"]."' /&gt;
      &lt;input type='hidden' class='userid' value='".$row["userid"]."' /&gt;
      &lt;button type='submit' class='getdata'&gt;&lt;/button&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>