新到阿贾克斯,所以问一个很基本的问题。
New to ajax, so asking a very basic question.
- 请问有没有办法做一个同步调用Ajax(异步:假的)?有超时设置就可以了。
-- Is there no way to make a Synchronous ajax call (async:false) with timeout set on it.?
http://www.ajaxtoolbox.com/request/
超时可以完美兼容异步调用,虽然在我的应用程序, 但对于一个特定的情况下,我需要一个同步调用(JavaScript的其实应该等待,直到它听到回从服务器),这也能正常工作。但我需要处理这样一个场景,断绝可能需要很长时间和AJAX超时都可能被调用。
Timeout works perfect with Asynchronous call though in my application, but for one particular scenario, I need a Synchronous call (the javascript should actually wait untill it hears back from the server), and this also works fine. But I need to handle a scenario where the sever could take long and a ajax timeout may be called.
有没有其他的片标准文档中阿贾克斯,我可以参考?
Is there any other piece of standard documentation for ajax I could refer to?
感谢
我不相信有可能在同步调用设置超时。当您设置异步:假,我相信,浏览器实际上锁定了,而等待响应。您应该只使用一个同步的请求,如果你确实需要(因为锁定浏览器)。
I don't believe it's possible to set a timeout on a synchronous call. When you set "async:false", I believe the browser actually locks up while waiting for the response. You should only use a synchronous request if you absolutely need to (because of the browser locking up).