title: Showing all the results of a loop with javascript?
body: <p>Im lost. Im new to javascript/jQuery. I've made this loop to loop through JSON stuff:</p>
  
  <pre><code>  &lt;script type="text/javascript"&gt;
     var geturl = "http://couponsforweed.com/?json=get_recent_posts";
  
              $.ajax({
  
                  type:'GET',
                  url:geturl,
                  complete: function(){                    
                  },
                  success: function (data) {
  
                      var response = data; //JSON.parse(data);
  
                      // it works!
                      alert("status: " + response.status + "\ncount: " + response.count + "\npages: " + response.pages + "\ncount_total: " + response.count_total + "\nposts: " + response.posts.length);
  
  
                      //loop through posts
                      for(var i = 0; i != response.posts.length; i++) {
  
                          //get each element in the array
                          var post = response.posts[i];
  
  
                          // output stuff so we can see things
                          output.innerHTML = i + " post: " + post.custom_fields.schemaState;
  
                      }
  
  
                  },
                  error:function (xhr, ajaxOptions, thrownError) {                    
                      alert("Error");
  
                  }
  
              });
    &lt;/script&gt;
  </code></pre>
  
  <p>It works, Im pleased with myself for getting that to work. But heres my problem:</p>
  
  <pre><code>// output stuff so we can see things
     output.innerHTML = i + " post: " + post.custom_fields.schemaState;
  </code></pre>
  
  <p>How come this only gives me the last result in the loop and not a list of all the results in the loop?</p>
  
  <p>I get:</p>
  
  <p>9 Ca</p>
  
  <p>I would like to see (each result in the loop):</p>
  
  <p>1 Ca
  2 Ca
  3 Ca
  4 Ca
  5 Co
  6 Wa
  7 Co
  8 Ca
  9 Ca</p>
  
  <p>Im used to PHP loops in WordPress where you can cycle though all the fields of each post and get the results accordingly. </p>