title: How to retrieve hidden TD value from an ajax request
body: <p>I am wondering how could I retrieve a value from a td. I am working with displaying data from the database in the html table. I want to display all columns except for the "id" field which is set to be hidden.</p>
  
  <p>I am using this jquery code:</p>
  
  <pre><code>function update(){
  var $id = $(this).closest("tr").find("#pid").text();  
      alert($id);
  }
  </code></pre>
  
  <p>Here's my ajax code:</p>
  
  <pre><code> $.ajax({
              type:'GET',
              url:'view.php',
              data:"",
              dataType: 'json',
              success:function(data){
              for(var i=0;i&lt;data.length;i++){
                  $("#body-data").append("&lt;td hidden='hidden' id='pid'&gt;"+data[i]['id']+"&lt;/td&gt;"+
                                         "&lt;td&gt;"+data[i]['name']+"&lt;/td&gt;"+
                                         "&lt;td&gt;"+data[i]['age'] +"&lt;/td&gt;"+
                                         "&lt;td&gt;"+data[i]['gender'] +"&lt;/td&gt;"+
                                         "&lt;td&gt;"+data[i]['email'] +"&lt;/td&gt;"+
                                         "&lt;td&gt;"+data[i]['address'] +"&lt;/td&gt;"+
                                         "&lt;td&gt;&lt;button class='btn btn-warning' onclick='update();'&gt;Update&lt;/button&gt;&lt;/td&gt;");
              }
              },
  
          });
  </code></pre>
  
  <p>I've tried anything to retrieve the id from an appended data in the html table but it just display nothing but blank.</p>