<tfoot id='Lvfe0'></tfoot>
    1. <i id='Lvfe0'><tr id='Lvfe0'><dt id='Lvfe0'><q id='Lvfe0'><span id='Lvfe0'><b id='Lvfe0'><form id='Lvfe0'><ins id='Lvfe0'></ins><ul id='Lvfe0'></ul><sub id='Lvfe0'></sub></form><legend id='Lvfe0'></legend><bdo id='Lvfe0'><pre id='Lvfe0'><center id='Lvfe0'></center></pre></bdo></b><th id='Lvfe0'></th></span></q></dt></tr></i><div id='Lvfe0'><tfoot id='Lvfe0'></tfoot><dl id='Lvfe0'><fieldset id='Lvfe0'></fieldset></dl></div>

        <legend id='Lvfe0'><style id='Lvfe0'><dir id='Lvfe0'><q id='Lvfe0'></q></dir></style></legend>
      1. <small id='Lvfe0'></small><noframes id='Lvfe0'>

          <bdo id='Lvfe0'></bdo><ul id='Lvfe0'></ul>

        fetch、ajax 和 xhr 之间的区别

        时间:2023-10-02
      2. <legend id='WlONi'><style id='WlONi'><dir id='WlONi'><q id='WlONi'></q></dir></style></legend>

        <small id='WlONi'></small><noframes id='WlONi'>

          <tbody id='WlONi'></tbody>
              • <bdo id='WlONi'></bdo><ul id='WlONi'></ul>
              • <i id='WlONi'><tr id='WlONi'><dt id='WlONi'><q id='WlONi'><span id='WlONi'><b id='WlONi'><form id='WlONi'><ins id='WlONi'></ins><ul id='WlONi'></ul><sub id='WlONi'></sub></form><legend id='WlONi'></legend><bdo id='WlONi'><pre id='WlONi'><center id='WlONi'></center></pre></bdo></b><th id='WlONi'></th></span></q></dt></tr></i><div id='WlONi'><tfoot id='WlONi'></tfoot><dl id='WlONi'><fieldset id='WlONi'></fieldset></dl></div>

                  <tfoot id='WlONi'></tfoot>
                  本文介绍了fetch、ajax 和 xhr 之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  What is the difference between these 3 calling methods? I'm using fetch in my current project and don't see any real difference between them. Why does there need to be 30 different ways to do things in javascript XD.

                  Thanks.

                  解决方案

                  Ajax is a buzzword meaning "Making an HTTP request from JavaScript without leaving the page".

                  XMLHttpRequest and fetch are APIs, provided by browsers, which allow HTTP requests to be made from JavaScript.


                  XMLHttpRequest has been around since the 90s and is event-driven, requiring that you bind event listeners to detect when data has arrived.

                  fetch is newer and built around Promises, which are now the prefered way to do asynchronous operations in JavaScript. It is sufficiently well established to be supported everywhere significant except in Internet Explorer. It does, however, lack certain features (such as progress monitoring) that `XMLHttpRequest provides.


                  So in short, there are two (not 30) purpose-built ways to do Ajax, and one of them is modern.


                  For practical introductions on how to use either of them, MDN has you covered:

                  • Using XMLHttpRequest
                  • Using Fetch

                  There are also various libraries which wrap around fetch or XMLHttpRequest to provide APIs which are situationally more convenient (e.g. a consistent API between Node.js and browsers or integration with a framework like Angular).

                  这篇关于fetch、ajax 和 xhr 之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:答应我在使用回调时返回待处理状态 下一篇:无法使用 JavaScript 获取响应状态代码

                  相关文章

                  1. <i id='0LNP6'><tr id='0LNP6'><dt id='0LNP6'><q id='0LNP6'><span id='0LNP6'><b id='0LNP6'><form id='0LNP6'><ins id='0LNP6'></ins><ul id='0LNP6'></ul><sub id='0LNP6'></sub></form><legend id='0LNP6'></legend><bdo id='0LNP6'><pre id='0LNP6'><center id='0LNP6'></center></pre></bdo></b><th id='0LNP6'></th></span></q></dt></tr></i><div id='0LNP6'><tfoot id='0LNP6'></tfoot><dl id='0LNP6'><fieldset id='0LNP6'></fieldset></dl></div>
                    • <bdo id='0LNP6'></bdo><ul id='0LNP6'></ul>

                    <small id='0LNP6'></small><noframes id='0LNP6'>

                  2. <legend id='0LNP6'><style id='0LNP6'><dir id='0LNP6'><q id='0LNP6'></q></dir></style></legend>

                      <tfoot id='0LNP6'></tfoot>