title: ajax: responsetext returns my entire php code locally
body: <p>I found a good Tutorial: <a href="http://www.webmasterpro.de/coding/article/einfuehrung-ajax.html" rel="nofollow">tutorial</a></p>
  
  <p>but it doesn't work locally. 
  The Problem is, that the responsetext returns my entire php code. 
  I double-click at my ajaxclock.html and use Firefox.
  Surprisingly, it works on the server.</p>
  
  <p>Here the code:
  ajaxclock.html</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
  &lt;head&gt;
      &lt;title&gt;AJAX Tutorial&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div id="time"&gt;&lt;/div&gt;
      &lt;button onclick="getTime();"&gt;Aktualisieren&lt;/button&gt;
      &lt;script type="text/javascript" src="script.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p>script.js </p>
  
  <pre><code>var req = getXmlHttpRequestObject();
  window.onload = getTime();
  
  function getXmlHttpRequestObject()
  {
      if(window.XMLHttpRequest) 
      {
           return new XMLHttpRequest();
      } 
      else if(window.ActiveXObject) 
      {
          return new ActiveXObject("Microsoft.XMLHTTP");
      } 
      else 
      {
          alert('Ajax funktioniert bei Ihnen nicht!');
      }
  }
  
  function getTime()
  {
      if(req.readyState == 4 || req.readyState == 0) 
      {
          req.open('GET', 'ajaxclock.php', true);
          req.setRequestHeader("Content-Type","text/plain");
          req.onreadystatechange = setMessage;
          req.send(null);
      }
  }
  
  function setMessage()
  {
      if(req.readyState == 4) 
      {
          var response = eval('(' + req.responseText+ ')');
          document.getElementById('time').innerHTML = response.time;
      }
  }
  </code></pre>
  
  <p>ajaxclock.php</p>
  
  <pre><code>&lt;?php echo '{"time": "'.date("H:i:s").'"}'; ?&gt;
  </code></pre>