Giter Site home page Giter Site logo

async:false无效 about ajax HOT 3 CLOSED

gerryiswarrior avatar gerryiswarrior commented on May 28, 2024
async:false无效

from ajax.

Comments (3)

GerryIsWarrior avatar GerryIsWarrior commented on May 28, 2024

在同步下的注意规则:
* xhr.timeout必须为0
* xhr.withCredentials必须为 false
* xhr.responseType必须为""(注意置为"text"也不允许)

之前在配置该参数的时候赋值为默认值,但是在有些浏览器直接不允许赋值,否则会给你报错。该问题已解决。

同步请求在浏览器会给出警告:主线程上的同步XMLHttpRequest由于其对最终用户体验的不利影响而被弃用。 这个方法可能会被弃用不建议使用。且最新的API提供了promise和async await来处理异步。不过具体还需要结合自己需求使用。

问题已修复,浏览器已测试,感谢使用~(npm 需要重新安装一下,直接引入的话就拉一下最新的js文件就可以了)

from ajax.

beausoft avatar beausoft commented on May 28, 2024

再同步的情况下,只能用get方式吗?

from ajax.

GerryIsWarrior avatar GerryIsWarrior commented on May 28, 2024

post也可以用的,不过需要用common方法设置async=
false,因为常用方法没有总结这个,官方API也不推荐使用的,所以没有提供常用方法

from ajax.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.