title: How to increment the value of jquery selector
body: <p>Consider the following Jquery Ajax looping a PHP script. I have a few problems with it because it appends the first div with content from server but the rest of the divs are empty, i guess that's because of duplicated IDs</p>
  
  <p>1st Question . As this is possible, </p>
  
  <pre><code>$("&lt;span id='name" + counter + "'&gt;&lt;/span&gt;")
  </code></pre>
  
  <p>as you can see, I'm adding "1" to the id "#name" every time it's appended, so the first span's id is "name1" and follows "name2 and so on"</p>
  
  <p>i also want to increment this selector:</p>
  
  <p>$('#name').html(feedback.name) </p>
  
  <p>e.g, the first selector should be 
      $('#name1').html(feedback.name) </p>
  
  <p>and the second be, 
      $('#name2').html(feedback.name)</p>
  
  <p>and so on.
  what's the right syntax for that? </p>
  
  <p>2nd Question: </p>
  
  <p>Consider this.</p>
  
  <pre><code>$("&lt;span id='name" + counter + "'&gt;&lt;/span&gt;")
  </code></pre>
  
  <p>is there anyway i can load that div from somewhere else and achieve the same results as below without going through same origin policy issues? If JSONP will help please suggest some structure i can use.</p>
  
  <p>Full Jquery Ajax Code: </p>
  
  <pre><code>var get_fb = (function(){
      var counter = 0;
      var $buzfeed = $('#BuzFeed');
      return function(){
          $.ajax({
              dataType : 'json',
              type: "GET",
              url: "Algor.php"
          }).done(function(feedback) {
              counter += 1;
              var $buzfeedresults = 
  $("&lt;span id='name" + counter + "'&gt;&lt;/span&gt;");
              $('#name').html(feedback.name); 
              $buzfeedresults.append(feedback);
              $buzfeed.append($buzfeedresults);
              var $buzfeedDivs = $buzfeed.children('div');
              if ($buzfeedDivs.length &gt; 7) { $buzfeedDivs.last().remove(); }
              setTimeout(get_fb, 2000);
          })
      };
  })();
  get_fb();
  </code></pre>
  
  <p>Thanks in advance.</p>