title: reference error can't find xmlhttp
body: <p>Trying to get my code to connect to API and retrieve a list of local farmers markets but keep getting Reference error that <code>xmlhttp</code> is not defined on line 40. Haven't caught any spelling errors and have tried moving chunks of code to see if they work at different positions.</p>
  
  <pre><code>&lt;html&gt;
  
      &lt;head&gt;
          &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
          &lt;meta charset="UTF-8"&gt;
  
          &lt;title&gt;Markets&lt;/title&gt;
          &lt;script&gt;
              window.onload = function() {
  
                  function myFunction(arr) {
                      out = "&lt;h1&gt;Markets&lt;/h1&gt;";
                      var i;
                      for (i = 0; i &lt; array.results.length; i++) {
                          out = out + "&lt;em&gt;" + item.marketname + "&lt;/em&gt;&lt;br&gt;" + details.marketdetails.Address + "&lt;/p&gt;"
                          arr.results.forEach(printDetails)
  
                      }
                      document.getElementById("market_details").innerHTML = out;
                  }
  
                  var mybutton = document.getElementById("submit_btn")
                  mybutton.onclick = function() {
  
                      var xmlhttp = new XMLHttpRequest();
                      var zip = document.getElementById("zip").value
                      var url = "http://search.ams.usda.gov/farmersmarkets/v1/data.svc/zipSearch?zip=" + zip;
  
                      xmlhttp.onreadystatechange = function() {
                          if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
                              var myArr = JSON.parse(xmlhttp.responseText);
                              myFunction(myArr);
                          }
                      }
                  };
  
                  xmlhttp.open("GET", url, true);
                  xmlhttp.send();
              }
  
              itemsProcessed = 0
  
              function printDetails(item, index, array) {
  
                  console.log(item.marketname)
  
                  var xmlhttp = new XMLHttpRequest();
                  var url2 = "http://search.ams.usda.gov/farmersmarkets/v1/data.svc/mktDetail?id=" + id;
  
                  xmlhttp.onreadystatechange = function() {
                      if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) {
                          var myDArr = JSON.parse(xmlhttp.responseText);
                          details = myDArr
  
                          //console.log(myDArr.marketdetails)
  
                      };
                      xmlhttp.open("GET", url2, true);
                      xmlhttp.send();
  
                      itemsProcessed++
                  }
              }
  
          &lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;h1&gt; Find Your Local Market!&lt;h1&gt;
       Enter Zip Code:&lt;input id="zip"&gt;&lt;/p&gt;&lt;br&gt;
      &lt;button id = "submit_btn"&gt;Submit&lt;/button&gt;
      &lt;div id="market_details"&gt;&lt;/div&gt;
      &lt;/body&gt;
  </code></pre>