Javascript ajax发送了一个请求,但得到了err_empty_响应
最近,我输入了一个关于err_empty_响应的问题。我向服务器发送了一个ajax请求,但得到了一个带有err\u empty\u resonse的响应。以下是代码:Javascript ajax发送了一个请求,但得到了err_empty_响应,javascript,http,Javascript,Http,最近,我输入了一个关于err_empty_响应的问题。我向服务器发送了一个ajax请求,但得到了一个带有err\u empty\u resonse的响应。以下是代码: $.ajax("/wordpress/api/sync_agent_and_estate/", { success: function(data){ if(data['status'] == 'success'){ //start to sync up agent and prope
$.ajax("/wordpress/api/sync_agent_and_estate/", {
success: function(data){
if(data['status'] == 'success'){
//start to sync up agent and property
else{ 55,1 12%
alert('Failed to sync: ' + data['message']);
}
},
error: function(data){
alert('Failed to sync properties and agents.');
}
});
chrome很早就得到了err_empty_响应,但服务器仍在执行。
请求可能需要1-2分钟。
请帮帮我,谢谢
以下是后端代码:
@company_login_required
def sync_agent_and_estate_view(request):
company = get_current_company(request)
domain_url = company.get_wordpress_domain()
wp_client = WordPressClient('http://' + domain_url + '/xmlrpc.php',
settings.WORDPRESS_USERNAME,
settings.WORDPRESS_PASSWORD)
post_user = get_wp_user(wp_client, company)
# Check account has been activiated and theme set to wp-residence
check_result = check_wp_client(wp_client, company)
if check_result and check_result["status"] == "failed":
return json_response(check_result)
# Sync estates and agents
agent_list = cmsUser.objects.filter(company=company.id)
agent_post_dict = get_agent_post_dict(wp_client)
estate_post_dict = get_estate_post_dict(wp_client)
for agent in agent_list:
existed_agent_post = agent_post_dict.get(str(agent.id), None)
agent_post = sync_agent(
wp_client, agent, existed_agent_post, post_user)
# If the property is in-activated, it should be synced to wordpress too
estate_list = estate.active_estate.filter(owner=agent)
# Do a batch update of RETS GPS query first
mls_list = estate_list.values_list("mls_number", flat=True)
mls_list = list(mls_list)
rets_gps_dict = {}
rets_query_url = "http://" + settings.APICENTER_DOMAIN + \
"/idx/estate_search_by_mls/?type=map" + \
"&listing_id_list=" + ",".join(mls_list) + \
"&mred_region=" + settings.MRED_REGION + \
"&listing_office_id=" + company.company_office_id
result = wp_common_request(rets_query_url)
for item in result:
rets_gps_dict[item["mls_number"]] = (item["LAT"], item["LNG"])
geocoder = Geocoder()
for estate_item in estate_list:
coordinate = rets_gps_dict.get(estate_item.mls_number, None)
if not coordinate:
coordinate = get_coordinate_for_estate(estate_item, geocoder)
estate_post = estate_post_dict.get(str(estate_item.id), None)
sync_estate(wp_client, estate_item, estate_post,
agent_post, post_user, coordinate)
return json_response({"status": "success"})
请分享您试图获取数据的后端逻辑。我尝试了chrome和firefox,它们都有相同的问题。我认为apache设置或php设置有问题,请求使用代理。我清除了chrome历史记录数据,响应成功,但我重试,失败