[英]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. 重新加载页面并第一次执行脚本后,我得到了
(failed) net::ERR_CONNECTION_REFUSED
,此后一切正常。 Any ideas why? 有什么想法吗?
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和jquery的整个脚本,因为它太长了(〜1200行合计),而是我将发布负责请求发生的部分。
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: jQuery或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. 如果这些信息还不够多,请随时发布我的所有代码(如果需要的话)。
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 .
这仅在Chrome上发生 ,并且如果您在刷新页面后立即发出请求 。 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.
我在Firefox上进行了尝试 ,它的工作方式就像应该刷新页面还是不刷新。 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.
在这一点上, 我怀疑我发现了某种Chrome错误 (不太可能), 或者我的扩展程序或其他干扰。
Turn ing AdBlock off helped. 关闭荷兰国际集团的AdBlock关闭帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.