同步XMLHttpRequest polyfill

时间:2016-05-27 18:28:44

标签: javascript ajax

我正在做一个实验,看看我是否可以使用eval'd的同步ajax调用替换函数体

我知道他们已被弃用,使用它们是个坏主意,但我想不出另一种方法可以做到这一点。

有没有办法让异步ajax调用同步?

我尝试过使用while (request.readyState !==); 但这似乎也阻止了请求

1 个答案:

答案 0 :(得分:0)

使用

Widget build(BuildContext context) {
    return Stack(
      overflow: Overflow.visible,
      children: [
        Container(
          width: 200,
          height: 200,
          decoration: BoxDecoration(
            border: Border.all(),
          ),
          child: const Center(child: Text("BLABLABLA")),
        ),
        Positioned(
          top: -10,
          left: 10,
          child: Container(
            width: 150,
            height: 25,
            decoration: BoxDecoration(
              border: Border.all(),
            ),
            child: const Center(child: Text("BLABLABL2")),
          ),
        ),
      ],
    );
  }

或者更好地使用

<script>
document.write("<script src=/path/to/your/js/file.js><\/script>")
</script>

该代码将在页面上执行任何进一步的代码之前加载并执行。