同步请求URL [英] Syncronous Request For a URL

查看:136
本文介绍了同步请求URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我在javascript中使用xmlHttpRequest请求一个网址.而且我想显示一个加载器或进度条,直到请求没有得到响应的URL.

现在,我使用异步方式实现了这些功能,但是我想使用同步方法来显示加载器,当我使用同步方式时,浏览器无法看到任何加载器或进度条.

您能否让我知道我做了什么,以便我能够做到这一点.

谢谢.

Hello,

I am requesting one url using xmlHttpRequest in javascript. And i want to show one loader or progress bar until request not getting response for url.

Now, i achieve that things using Asynchronously but i want to show loader using synchronous method and when i used synchronous way the browser not able to seen any loader or progress bar.

Could you please let me know what i do so that i can achieve that.

Thanks.

推荐答案

这将永远无法工作.如果显示进度的方法仍保留在函数调用中(在我假定的循环中),则不会对GUI前端进行任何可见的更新,并且您的应用程序似乎已冻结.进度栏或加载器指示器的显示也必须异步工作.我建议您使用计时器对进度条/加载器进行更改,直到收到指示URL已完全加载的指示.

干杯!

—MRB
This will never work. If your method showing the progress would remain in a function call (in a loop I''d presume) there would be no visible updates to the GUI frontend and your application would seem to be frozen. The display of your progressbar or loader indicator will also have to work asynchronously. I suggest you use a timer to make the changes to your progressbar / loader until the indication was received that the URL has been fully loaded.

Cheers!

—MRB


这篇关于同步请求URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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