Ajax发帖,未收到回复
目前我正在做一篇 jQuery post 从服务器获取一些数据。 在标准情况下,会返回较大的 JSON。
该调用第一次运行时需要大量的处理时间(我见过长达 15 分钟。我们确实计划创建工作进程来在幕后构建这些进程并将进度中继到客户端)。完成后,我们将其存储在缓存中并将 JSON 返回给用户。
在这两种情况下,我们都会向客户端返回完全相同的 JSON,唯一的区别是,如果构建了缓存,则在几毫秒内返回,如果未构建缓存,则客户端可能需要很长时间才能接收到回复。
当它在服务器上运行时,如果请求花费很长时间,客户端永远不会收到 ajax 响应,但服务器会完成该过程(访问日志显示 200 statusCode)并存储缓存。作为在我的本地主机上的参考,无论时间如何(或者到目前为止我所看到的),总是会收到ajax响应。
简而言之,我们做了一个ajax post,如果需要很长时间,则永远不会收到post响应并最终无限期地等待。
这听起来像是 PHP 或服务器端设置,但我似乎找不到问题。
非常感谢任何想法或帮助。
Currently I am doing a jQuery post to fetch some data from the server.
In standard circumstances a large JSON is returned.
The first time this call runs it requires a large amount of processing time, (I've seen up to 15 minutes. We do have plans to create worker processes to build these behind the scenes and relay progress to the client) after the processing has completed we store this in a cache and return the JSON to the user.
In both scenarios we return exactly the same JSON to the client, the only difference being, if the cache is built it is returned in a few milliseconds, if the cache is not built, it can take a long time for the client to receive the response.
When this is running on the server, if the requests takes a long time the client never receives the ajax response but the server does complete the process (access logs show 200 statusCode) and store the cache. For reference on my localhost the ajax response is always received, regardless of time (or so I have seen thus far).
In a nutshell, we make a ajax post, if it takes a long time, the post response is never received and ends up waiting indefinitely.
This sounds like it is either a PHP or server side setting, but I can't seem to find the issue.
Any ideas or help are much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您需要增加 ajax 请求的超时时间?
超时是基本 jquery ajax 方法上的一个选项 - http://api.jquery.com/jQuery.ajax /
Sounds like you need to increase the timeout on the ajax request?
timeout is an option on the base jquery ajax method - http://api.jquery.com/jQuery.ajax/