• <tfoot id='cVyRZ'></tfoot>
    1. <legend id='cVyRZ'><style id='cVyRZ'><dir id='cVyRZ'><q id='cVyRZ'></q></dir></style></legend>

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

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

        • <bdo id='cVyRZ'></bdo><ul id='cVyRZ'></ul>

        在同一来源上发出 XMLHttpRequest 时,有没有办法不

        时间:2023-10-14

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

          <bdo id='O2xQw'></bdo><ul id='O2xQw'></ul>
            <tbody id='O2xQw'></tbody>
          <legend id='O2xQw'><style id='O2xQw'><dir id='O2xQw'><q id='O2xQw'></q></dir></style></legend>

                • <i id='O2xQw'><tr id='O2xQw'><dt id='O2xQw'><q id='O2xQw'><span id='O2xQw'><b id='O2xQw'><form id='O2xQw'><ins id='O2xQw'></ins><ul id='O2xQw'></ul><sub id='O2xQw'></sub></form><legend id='O2xQw'></legend><bdo id='O2xQw'><pre id='O2xQw'><center id='O2xQw'></center></pre></bdo></b><th id='O2xQw'></th></span></q></dt></tr></i><div id='O2xQw'><tfoot id='O2xQw'></tfoot><dl id='O2xQw'><fieldset id='O2xQw'></fieldset></dl></div>
                  <tfoot id='O2xQw'></tfoot>
                • 本文介绍了在同一来源上发出 XMLHttpRequest 时,有没有办法不发送 cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在开发一个为用户解析 gmail rss 提要的扩展程序.如果他们不想保持登录状态,我允许用户指定用户名/密码.但是,如果用户已登录并且提供的用户名/密码用于不同的帐户,则这会中断多次登录.所以我想避免发送任何 cookie,但仍然能够在 send() 调用中发送用户名/密码.

                  I'm working on an extension that parses the gmail rss feed for users. I allow the users to specify username/passwords if they don't want to stay signed-in. But this breaks for multiple sign-in if the user is signed-in and the username/password provided is for a different account. So I want to avoid sending any cookies but still be able to send the username/password in the send() call.

                  推荐答案

                  从 Chrome 42 开始,fetch API 允许 Chrome 扩展(以及Web 应用程序)来执行无 cookie 请求.HTML5 Rocks 提供了有关使用 fetch API 的介绍性教程.

                  As of Chrome 42, the fetch API allows Chrome extensions (and web applications in general) to perform cookie-less requests. HTML5 Rocks offers an introductory tutorial on using the fetch API.

                  fetch 的高级文档目前非常稀少,但 规范中的 API 接口 是一个很好的起点.接口下面描述的 fetch 算法显示 fetch 生成的请求默认是没有凭据的!

                  Advanced documentation on fetch is quite sparse at the moment, but the API interface from the specification is a great starting point. The fetch algorithm described below the interface shows that requests generated by fetch have no credentials by default!

                  fetch('http://example.com/').then(function(response) {
                      return response.text(); // <-- Promise<String>
                  }).then(function(responseText) {
                      alert('Response body without cookies:
                  ' + responseText);
                  }).catch(function(error) {
                      alert('Unexpected error: ' + error);
                  });
                  

                  如果你想要真正的匿名请求,你也可以禁用缓存:

                  If you want truly anonymous requests, you could also disable the cache:

                  fetch('http://example.com/', {
                      // credentials: 'omit', // this is the default value
                      cache: 'no-store',
                  }).then(function(response) {
                      // TODO: Handle the response.
                      // https://fetch.spec.whatwg.org/#response-class
                      // https://fetch.spec.whatwg.org/#body
                  });
                  

                  这篇关于在同一来源上发出 XMLHttpRequest 时,有没有办法不发送 cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Access-Control-Allow-Origin 不允许 XMLHttpRequest Origin 下一篇:Access-Control-Allow-Origin 不允许来源 http://localhost

                  相关文章

                  最新文章

                  <legend id='OnGrI'><style id='OnGrI'><dir id='OnGrI'><q id='OnGrI'></q></dir></style></legend>
                  <tfoot id='OnGrI'></tfoot>

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

                    1. <small id='OnGrI'></small><noframes id='OnGrI'>

                      • <bdo id='OnGrI'></bdo><ul id='OnGrI'></ul>