Can one replace xhr.onreadystatechange with xhr.onload for AJAX calls?

前端 未结 4 1020
星月不相逢
星月不相逢 2020-12-08 06:30

I need to support major modern browsers only (IE10+, FF, Chrome, Safari)

Can I make this substitution as I want to simplify my code base:

From:

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-08 06:43

    Since the original asker said "I need to support major modern browsers only (IE10+, FF, Chrome, Safari)" it is obvious that onload, onerror, etc are the ways to go. Also, as of today, onreadystatechange is pretty much obsolete, as you are obviously not going to support anything that old that it supports onreadystatechange only.

    To sum it up, forget about onreadystatechange.

提交回复
热议问题