如何使用 YUI 制作同步/阻塞 XMLHttpRequest

发布于 2024-09-09 01:37:28 字数 231 浏览 0 评论 0原文

这里有很多问题都在问这个问题,但答案总是只是告诉人们他们真正想要一个异步请求,而不是实际回答如何使用 YUI 执行同步请求的问题。我知道如何使用 jQuery 以及直接操作 XMLHttpRequest 对象,但是在使用 YUI 时如何做到这一点(无需深入挖掘它的内部结构来找到它最终将使用和操作的 XMLHttpRequest 对象)?

在有人问之前:是的,我知道大多数时候您确实需要异步,但有时同步确实是完成这项工作的正确工具。

There are a number of questions here that ask this but the answers invariably just tell the person they really want an Asynchronous request rather than actually answering the question of how to do a Synchronous request with YUI. I know how to do one with jQuery and when directly manipulating the XMLHttpRequest object but how do you do it when using YUI (without digging through it's guts to find the XMLHttpRequest object it will ultimately be using and manipulating that)?

Before someone asks: yes I am aware that most of the time you do want Asynchronous, but sometimes Synchronous really is the right tool for the job.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

允世 2024-09-16 01:37:28

这是在 YUI 3 中如何操作

我使用 YUI 3,所以这是基于对代码和文档的快速查看,但对于 YUI 2 来说,答案似乎是“否”。您可以尝试覆盖 YAHOO.util.Connect.createXhrObject(),但我认为这将是一个真正的痛苦,正如其余代码所期望的那样事情是异步的。您最好使用另一个库来处理代码的同步请求部分。

Here's how to do it in YUI 3.

I use YUI 3, so this is based on a quick look at the code and docs, but it looks like the answer is "no" for YUI 2. You could try overriding YAHOO.util.Connect.createXhrObject(), but I think this is going to be a real pain, as the rest of the code expects things to be asynchronous. You're better off using another library for the synchronous request portion of your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文