Ajax Post 请求阻止网站加载

发布于 2024-12-09 03:33:59 字数 301 浏览 1 评论 0原文

我在使用 ajax post 请求时遇到一个奇怪的问题。我使用 php 函数 exec() 直接在命令行上运行 ImageMagick 进程。该过程大约需要一分钟,然后用一些变量进行响应。除了一个问题之外,这工作正常。在执行期间,我不能超出安装在同一网络服务器上的网站的其他部分(就好像服务器无法访问一样)。当该过程完成后,一切都会恢复正常。

我首先认为这是由于服务器过载造成的。但是,当您通过其他浏览器访问该网站时,即使在其他浏览器中的进程执行期间,也没有问题。因此,问题似乎与浏览器在发布请求期间阻止其他请求有关。

有人可以帮我吗?根本问题可能是什么?

I have a strange problem with using ajax post requests. I use the request to run an ImageMagick process directly on the command line by using php function exec(). The process takes about a minute, and then responds with some variables. This is working fine, except from one problem. During the execution time I cannot excess other parts of the website that are installed on the same webserver (as if the server is unreachable). When the process finishes, everything works fine again.

I first thought this to be due to an overloaded server. However, when you access the website via another browser, there are no problems, even during the execution time of the process in the other browser. So it looks like the problems has something to do with browsers blocking other requests during the post request.

Could anyone help me out here? What could be the root problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

著墨染雨君画夕 2024-12-16 03:33:59

找到解决方案了!感谢 kukipei 的帮助 通过添加 session_write_close();到ajax请求的文件中(在读取了用户ID和令牌之后),会话文件不再被锁定,并且所有页面都可以再次访问。问题是会话在进程的整个执行时间内被锁定,这是没有必要的,因为我只需要会话来读取用户 ID 和令牌。所以在调用ImageMagick操作之前,我现在添加session_write_close()

Found the solution! Thanks from the help by kukipei By adding session_write_close(); to the file of the ajax request (after is has read the userid and token), the session file is no longer locked, and all pages are accessible again. Problem was that the session was locked during the whole execution time of the process, which was not necessary, since I only needed the session to read the userid and token. So before calling the ImageMagick operation, I now add session_write_close()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文