Jquery, Ajax (failed) net::ERR_CONNECTION_REFUSED
Clash Royale CLAN TAG#URR8PPP
Jquery, Ajax (failed) net::ERR_CONNECTION_REFUSED
I'm getting (failed) net::ERR_CONNECTION_REFUSED
after i reload my page and execute the script first time, after that it works just fine. Any ideas why?
(failed) net::ERR_CONNECTION_REFUSED
I won't post the whole script of my python and jquery because it will be too long(~1200 lines combined), rather I will post the parts that are responsible for the request to happen.
Python:
class testHTTPServer_RequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
self.send_response(200)
self.send_header('Content-type','application/json; charset=utf-8')
self.send_header('Access-Control-Allow-Origin', 'http://localhost')
self.end_headers()
content_length = int(self.headers['Content-Length'])
body = self.rfile.read(content_length)
parsed_q = urlparse(self.path)
parsed_b = urlparse(body.decode("utf-8"))
search_info = urllib.parse.parse_qs(parsed_q.query)
user_info = urllib.parse.parse_qs(parsed_b.path)
luk = ''.join(search_info['search'])
wer = ''.join(search_info['parde'])
user_id = ''.join(user_info['user'])
self.wfile.write(bytes(where_to(luk, wer, user_id), "utf8"))
return
def do_GET(self):
print ("get request...")
self.send_response(200)
self.send_header('Content-type','text/html; charset=utf-8')
self.send_header('Access-Control-Allow-Origin', '*')
self.end_headers()
message = "Nothing to see here."
self.wfile.write(bytes(message, "utf8"))
return
Jquery or Ajax:
else
$(".peenum").html("");
$(".cont_row").html("");
$('.progress-bar').css("width": "0%")
var dat = Cookies.get()
$(".where").each(function()
var url = 'http://localhost:8081/?search='+$("#enter_look_for").val()+'&parde='+$(this).val();
$.ajax(
url: url,
method: "POST",
data: dat,
success: pajiehali
);
);
If this information isn't enough feel free to ask, I'll post all of my code if that's what it takes to figure it out.
Yea, I was just thinking about that too, tried it as well. It seems that it doesn't even connect to the server, nothing shows up on the console...
– Duma
Aug 7 at 10:37
It act's as if the server wasn't on.
– Duma
Aug 7 at 10:49
1 Answer
1
Okay, so I would like to fill you guys in, hoping that I could get some answers, because I'm really clueless here. This only happens on Chrome, and if you do a request right after the page refresh. If you wait a bit after refreshing the page it works fine. I tried it on Firefox and it worked like it was supposed to refreshing the page or not. At this point I'm suspecting that i found a some kind of Chrome bug(that's unlikely), or my extensions or something else is interfering.
Turning AdBlock off helped.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
possibility is that at first time your request takes more time than afterward. you could increase the timeout time for the ajax call by setting timeout: 20000 and check if it works
– umer
Aug 7 at 10:18