XMLHttpRequest is deprecated. What to use instead?

前端 未结 3 694
没有蜡笔的小新
没有蜡笔的小新 2021-02-08 18:14

Trying to use a pure JS approach to check if I have a valid JS image url. I am getting a warning that XMLHttpRequest is deprecated. What is a better way to do this?

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-08 18:25

    The cause of the warning was that in http.open('HEAD', url, false); you put a third argument (async) as false. As per the https://xhr.spec.whatwg.org/#synchronous-flag it should be set to true.

提交回复
热议问题