How do you make a synchronous / blocking XMLHttpRequest with YUI
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.
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.
链接地址: http://www.djcxy.com/p/55334.html