+ 3
Why is my xhr requests pending?
I'm catching requests with HTTPServer and BaseHTTPRequestHandler class Server(BaseHTTPRequestHandler): def do_GET(self): self.response(200, { "Content-type": "text/html", "Access-Control-Allow-Origin": "*" }) self.write("success") def write(self, text): self.wfile.write(bytes(text, "utf-8")) def response(self, code, headers): self.send_response(int(code)) for key in headers: self.send_header(key, headers[key]) self.end_headers() server = HTTPServer(("localhost", 3000), Server) server.serve_forever() When viewed from browser it works perfectly. But when sent with javascript it receives the requests but it doesn't send the response status which leaves the request hanging.
9 Respuestas
+ 2
Okay so. The problem was that I had youtube open. Or if any other side is loading in a new tab. My internet shouldn't be that bad tho...
+ 1
Nothing special about it
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
alert("success")
}
};
xhttp.open("GET", "http://localhost:3000", true);
xhttp.send();
Sometimes it success but with a huge delay
+ 1
Python version: 3.6
windows 10
google chrome and edge
Last request delay 43 seconds.
+ 1
Just for sure... Can you insert
self.wfile.flush()
at end of do_GET() ?
0
You have start serving?
server.serve_forever()
0
I presume that you have started serving because you have edited the code... Anyway, can you post the xhr code?
0
Strange... I have do some test and all worked normally...
Browser: Firefox 47.0.1 (used for either web and xhr request)
Python version: 3.6 on Windows 7 32b
Which are your specs?
0
😤😤😤
0
Hey but your connection is local, how you can get so mich delay? It dont depends on your internet connection