Home > Web Front-end > JS Tutorial > How to set ajax timeout (an action is executed twice)

How to set ajax timeout (an action is executed twice)

韦小宝
Release: 2017-12-31 10:22:58
Original
1902 people have browsed it

An action was executed twice. This operation took more than 5 minutes to complete, so I searched for a few places where I can set the timeout. I hope it will be helpful to everyone.

I found it while testing the project today. An action was executed twice. This operation took more than 5 minutes to complete. The engineering environment was apache2+tomcat6.0.

Online search found several places where timeout can be set:

1.ajax syntax to set the unit milliseconds, for example:

$.ajax({ 
url: XXX, 
timeout: 600000, 
type: 'POST', 
data: { 
}, 
error: function() { 
show_fail_meg("启动系统失败 !"); 
} 
});
Copy after login

2.tomcat configuration server.xml in milliseconds

Connector port="8080" protocol="HTTP/1.1" 
connectionTimeout="20000" 
redirectPort="8443" URIEncoding="UTF-8"/>
Copy after login

3.apache configuration file httpd.conf in seconds

# 
# Timeout: The number of seconds before receives and sends time out. 
# 
Timeout 60
Copy after login

After modifying the above several places, it was found that it still did not take effect. Finally, it was located in the mod_jk module.

mod_jk, referred to as JK, is the Apache server A pluggable module that provides Apache or IIS servers with the ability to process JSP/Servlets.

That is to say, the settings of JK may cover the settings of apache2, tomcat and ajax.

The content of JK’s configuration file/etc/httpd/conf/workers.properties is as follows:

worker.master.socket_timeout=300
Copy after login

Sure enough, I saw that this number is exactly 5 minutes, which is consistent with the abnormal phenomenon. After changing the size and restarting, it is normal!

The above is all the content of this article, I hope it will be helpful to everyone!

Related recommendations:

Ajax error handling method

How can ajax read local json

20 classic AJAX interview questions

The above is the detailed content of How to set ajax timeout (an action is executed twice). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template