我应该等待阿贾克斯完成重定向页面? [英] Should I wait for ajax to complete to redirect a page?

查看:251
本文介绍了我应该等待阿贾克斯完成重定向页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道的如何的等待AJAX​​来完成的,但如果我要重定向页面后,一些Ajax调用被解雇了,我要等他们重定向之前完成?有没有关系呢?

I know how to wait for ajax to complete, but if I'm going to redirect a page after some ajax calls are fired off, should I wait for them to complete before the redirect? Does it matter?

推荐答案

如果你有信心,Ajax调用会成功,那么一旦Ajax调用发生,重定向不会影响它只要您的服务器关心。但不要忘了,客户可能会失去他们的连接,或一些可能发生的错误,所以你可能需要等待,以确保调用是成功的。另一个要考虑的是你的Ajax调用是否会影响到任何网页你会重定向到。在这种情况下DEFINITELY等待重定向之前。你不会希望你的用户重定向到一个破碎的页面,因为它们的连接很慢或者服务器过打嗝。

If you're confident that the ajax call will be successful, then once the ajax call has occurred, redirecting won't affect it as far as your server is concerned. But don't forget, the client could lose their connection or a number of errors could occur, so you should probably wait to make sure the calls were successful. Another thing to consider is whether or not your ajax calls will affect whatever page you're going to redirect to. In that case DEFINITELY wait before redirecting. You won't want your user to get redirected to a broken page because their connection was slow or your server had a hiccup.

这篇关于我应该等待阿贾克斯完成重定向页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆