我只想问一下您的经历。 我正在设计一个公共网站,在大多数操作中都使用jQuery Ajax。 我有一些超时,我认为这应该是出于托管提供商的原因。 你们中的任何人在这种情况下都有经验,并且可能会在一些提示(尤其是超时处理)方面为我提供建议?</ p>

先谢谢大家。</ p>

史蒂夫</ p>
     </ div>



I just want to ask for your experience. I'm designing a public website, using jQuery Ajax in most of operations. I'm having some timeouts, and I think it should be for hosting provider cause. Any of you have expirience in this case and may advise me on some hints (especially on timeouts handling)?

Thanks in advance to all.



如果您的主机体面不错,则可能不是网络超时,而是由于硬件不足而导致服务器端脚本需要很长时间才能回答。 例如,如果您有一个自动完成字段,并且该脚本通过了100,000个条目的数据库,那么对于较新的服务器来说,这是轻而易举的事,但是较旧的“预算”服务器或拥挤的共享主机服务器可能会崩溃。 </ p>

取决于您的Ajax操作是什么,您可以将它们分解为更短的块。 例如,如果您要进行数据库查询,请使用LIMIT和OFFSET,一次仅返回5个条目。 当这5个条目到达客户端时,再进行一次Ajax调用,再调用5个条目,因此从用户的角度来看,这些条目将继续进入并且看起来很流畅(而不是等待30秒钟,并且可能会超时,然后他们才能看到所有条目)。 一旦)。 如果这样做,请确保显示一个漂亮的Web 2.0转盘,让用户知道他们是否应该等待更多时间或是否已经完成。</ p>
     </ div>



If you have a half-decent host, chances are these aren't network timeouts but are rather due to insufficient hardware which causes your server-side scripts to take too long to answer. For example if you have an autocomplete field and the script goes through a database of 100,000 entries, this is a breeze for newer servers but older "budget" servers or overcrowded shared hosting servers might croak on it.

Depending on what your Ajax operations are, you may be able to break them down in shorter chunks. If you're doing database queries for example, use LIMIT and OFFSET and only return say, 5 entries at a time. When those 5 entries arrive on the client, make another Ajax call for 5 more, so from the user's point of view the entries will keep coming in and it will look fluid (instead of waiting 30s and possibly timing out before they see all entries at once). If you do this make sure you display a spiffy web 2.0 turning wheel to let the user know if they should be waiting some more or if it's done.

Csdn user default icon