title: Jquery undefined after .each
body: <p>I'm getting undefined results from a .each called upon after a .post. The following is my code.</p>
  
  <p>Javascript</p>
  
  <pre><code>    var index=0;
      $("td.load_ads").each(function(){
          var loading=$(this);
          $.post('/self_coded_helpers/jpost_get_ads.php',{index:index,type:'fetch_id'},function(data){
              if($("input.exist").length &gt; 0){
                  $("input.exist").each(function(){
                      if($(this).val()==data){
                          var load='0';
                      }else{
                          var load='1';
                      }
                  });
              }else{
                  var load='1';
              }
              alert(load);
              if(load == 1){
                  $.post('/self_coded_helpers/jpost_get_ads.php',{index:index,type:'fetch_details',id:data},function(data2){
                      $("body").append('&lt;input type="hidden" class="exist" name="exist" value="'+data+'"&gt;');
                      if(data2!=0){
                          loading.html(load+'--'+data2);
                      }else{
                          loading.html("Place a Free Ad Now!");
                      }
                  });
              }else{
                  loading.html(load+"--"+data+"Place a Free Ad Now!");
              }
          });
          index=index+1;
      });
  </code></pre>
  
  <p>What I'm trying to do here is launch a .post on each of my td.load_ads, after which check the data with each existing input.val. If the input value on each of this existing inputs is the same as the data collected, then i will not echo out the second .post results. </p>
  
  <p>However, the whole operation doesn't seem to show correctly. I realise my problem is at the .each after the .post. When i did my alert(load). The results returned were undefined. Am i missing out something or is it that my coding is logically incorrect? Any help will be greatly appreciated.</p>
  
  <p><strong>/*<em>Added Problem</strong>/</em>* </p>
  
  <p>So now, I've another problem so I thought might as well just add it here. </p>
  
  <p>I try appending the inputs</p>
  
  <p>($("body").append('');) </p>
  
  <p>in the second section of the script.</p>
  
  <p>So that when the loop repeats itself, it will be able to read the input and take in the newly appended inputted values. But my load always returns 1 because my $("input.exist").length always returns false. </p>
  
  <p>Or is this not possible to do with jquery?</p>
  
  <p><strong>/*<em>END OF ADDED PROBLEM</strong>/</em>*</p>