title: “no 'Access-Control-Allow-Origin' header is present” error with Cherrypy
body: <p>I have the following javascript in a HTML page</p>
  
  <pre><code>&lt;script&gt;
      function getContent(page)
      {
          var xmlhttp;
          if (window.XMLHttpRequest)
              {// code for IE7+, Firefox, Chrome, Opera, Safari
                  xmlhttp=new XMLHttpRequest();
              }
          else
              {// code for IE6, IE5
                  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
              }
          xmlhttp.onreadystatechange=function()
          {
              if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
               {
                  var json = xmlhttp.responseText;
                  obj = JSON.parse(json);
                  document.getElementById("content").innerHTML=obj.content;
                  document.getElementById("title").innerHTML=obj.title;
               }
          }
      xmlhttp.open("GET","http://differentserver.com:8080?page="+page,true);
      xmlhttp.send();
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>and a python script using cherrypy that serves JSON, the code of which is:</p>
  
  <pre><code>import cherrypy
  import json
  
  class ContentGeneratorService(object):
  exposed = True
  @cherrypy.tools.accept(media='text/plain')
  def GET(self, page='home'):
      file_title = open(page + '.title', 'r')
      file_content = open(page + '.content', 'r')
      return json.dumps({"title": file_title.read().replace('\n', ''), "content":     file_content.read().replace('\n', '') })
  
  
  def CORS():
  cherrypy.response.headers["Access-Control-Allow-Origin"] = "*"
  
  if __name__ == '__main__':
  conf = {
      '/': {
          'request.dispatch': cherrypy.dispatch.MethodDispatcher(),
          'tools.sessions.on': True,
          'tools.response_headers.on': True,
          'tools.response_headers.headers': [('Content-Type', 'text/plain')],
          }
      }
  
  cherrypy.server.socket_host = '0.0.0.0'
  cherrypy.tools.CORS = cherrypy.Tool('before_handler', CORS)
  cherrypy.config.update({'server.socket_port': 8080})
  cherrypy.quickstart(ContentGeneratorService(), '/', conf)
  </code></pre>
  
  <p>However, I get a “no 'Access-Control-Allow-Origin' header is present” error. Is there a way to enable CORS with cherrypy?</p>
  
  <p>Thanks.</p>