Problem with Python server and Ajax on Firefox
Question: I have a simple Python server,

    
    
    import BaseHTTPServer
    import SimpleHTTPServer
    
    PORT = 8080
    
    class TestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
        def do_GET(self):
            self.wfile.write("ok")
    
    def start_server():
        """Start the server."""
        server_address = ("", PORT)
        server = BaseHTTPServer.HTTPServer(server_address, TestHandler)
        server.serve_forever()
    
    if __name__ == "__main__":
        start_server()
    

and I want to communicate with Ajax:

    
    
    $.ajax({
        type: "GET",
        url: 'http://localhost:8080',
        data: dataString,
        success: function(data) {
            alert(data)
        }
    });
    

But due to the cross-domain problem, URL = 'http://localhost:8080' doesn't
work with Firefox or Chrome. My code is OK on Internet Explorer.

How can I do to resolve my pb? My HTML file is on local
<http://localhost/test/> and my Python server is on <http://localhost:8080>,
and I want to communicate on the same domain.


Answer: Can't you just serve the local file via the same small Python server on
another URL? This will put them both in the same domain.

If you use Apache to serve your HTML page, you can proxy ([see
`ProxyPass`](http://httpd.apache.org/docs/2.0/mod/mod_proxy.html#proxypass))
your Python server so that it appears on the same domain and on the same port,
just under different URL.

