title: Getting data from Google docs into Javascript
body: <p>I try to get data from google spreadsheets and everything is allright when I'm testing html page locally. But when I load my html file and javascript file into server nothing works.</p>
  
  <p>Here is the code of html file "page.htm":</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;
  &lt;/title&gt;
  &lt;script type="text/javascript" src="teams.js" &gt;
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body
  onload= "Data();"&gt;
  &lt;table&gt;             
      &lt;form name="Team"&gt;
      &lt;tr&gt;                
          &lt;td&gt;
          &lt;input  size="19"  name="tName" readonly &gt;
          &lt;/td&gt;               
      &lt;/tr&gt;
      &lt;/form&gt;
      &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And js file "teams.js":</p>
  
  <pre><code>function Data() {
  var url="https://docs.google.com/spreadsheets/d/18WEeF3d9pJWYK1sheNHgc0KOi845cjyZgJ8x6TVisFM/pub?&amp;gid=0&amp;range=A1&amp;output=csv";
  
  xmlhttp=new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
      if(xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status==200){
        document.Team.tName.value = xmlhttp.responseText;
      }
    };
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
  }
  </code></pre>
  
  <p><a href="https://docs.google.com/spreadsheets/d/18WEeF3d9pJWYK1sheNHgc0KOi845cjyZgJ8x6TVisFM/edit#gid=0" rel="nofollow">Google doc</a></p>