久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <tfoot id='kVKe9'></tfoot>

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

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

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

        向所有 jQuery AJAX 請求添加自定義 http 標頭

        Add custom http header to all jQuery AJAX Requests(向所有 jQuery AJAX 請求添加自定義 http 標頭)
      2. <small id='hZRkv'></small><noframes id='hZRkv'>

              <tfoot id='hZRkv'></tfoot>
                <tbody id='hZRkv'></tbody>
            1. <i id='hZRkv'><tr id='hZRkv'><dt id='hZRkv'><q id='hZRkv'><span id='hZRkv'><b id='hZRkv'><form id='hZRkv'><ins id='hZRkv'></ins><ul id='hZRkv'></ul><sub id='hZRkv'></sub></form><legend id='hZRkv'></legend><bdo id='hZRkv'><pre id='hZRkv'><center id='hZRkv'></center></pre></bdo></b><th id='hZRkv'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='hZRkv'><tfoot id='hZRkv'></tfoot><dl id='hZRkv'><fieldset id='hZRkv'></fieldset></dl></div>
              <legend id='hZRkv'><style id='hZRkv'><dir id='hZRkv'><q id='hZRkv'></q></dir></style></legend>
                <bdo id='hZRkv'></bdo><ul id='hZRkv'></ul>

                  本文介紹了向所有 jQuery AJAX 請求添加自定義 http 標頭的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  澄清點:向我的 jQuery ajax 調用添加自定義標頭沒有任何問題,我希望將我的自定義標頭自動添加到所有 ajax 調用.

                  Point of clarification: I don't have any problem adding a custom header to my jQuery ajax call, I want to have my custom header added to all ajax calls automatically.

                  如果您查看 jquery $.ajax 自定義 http 標頭問題(不是我的問題),如果為每個 ajax 調用手動實現代碼,您將看到一個很好的示例.

                  If you take a look at jquery $.ajax custom http headers issue (not my question), you'll see a pretty good example of how the code works if implemented by hand for each ajax call.

                  我想為所有 jQuery ajax 調用覆蓋 beforeSend.根據 jQuery 文檔,我可以使用 jQuery.ajaxSetup() 來做到這一點,但是有一個警告說你可能不應該,可能會導致意外行為,所有這些東西.對于這種全局回調,他們建議使用 .ajaxStart()..ajaxStart() 看起來不錯,只是它沒有公開 XHR,所以我可以添加標題.

                  I'd like to override beforeSend for all jQuery ajax calls. According to the jQuery documentation I can do this by using jQuery.ajaxSetup(), but there is a warning saying you probably shouldn't, may cause unexpected behavior, all that stuff. For global callbacks of this kind they suggest using .ajaxStart(). .ajaxStart() looks great, except it doesn't expose the XHR so I can add the header.

                  我應該只使用 ajaxSetup 添加 beforeSend 嗎?有沒有辦法從 ajaxStart 訪問 XHR?其他選擇?

                  Should I just add beforeSend using ajaxSetup? Is there a way to access the XHR from ajaxStart? Other options?

                  推薦答案

                  預過濾器是實現此目的的簡單方法:

                  A pre-filter would be an easy way of accomplishing this:

                  $.ajaxPrefilter(function( options ) {
                      if ( !options.beforeSend) {
                          options.beforeSend = function (xhr) { 
                              xhr.setRequestHeader('CUSTOM-HEADER-KEY', 'CUSTOM-HEADER-VALUE');
                          }
                      }
                  });
                  

                  這樣所有請求都將獲得自定義標頭,除非特定請求覆蓋了 beforeSend 選項.

                  this way all requests will get the custom header, unless the specific request overrides the beforeSend option.

                  但是請注意,您可以使用 ajaxSetup 實現相同的目標.存在警告的唯一原因是因為使用它會影響所有 ajax 請求(就像我的方法一樣),如果特定請求不需要該選項集,可能會導致不需要的結果.我建議只使用 ajaxSetup,畢竟這就是它的用途.

                  Note however you can accomplish the same goal using ajaxSetup. the only reason that warning is there is because using it will affect all ajax requests (just like my method will), possibly resulting in unwanted results if a specific request didn't need that option set. I'd suggest just using ajaxSetup, that is what it's there for after all.

                  這篇關于向所有 jQuery AJAX 請求添加自定義 http 標頭的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內容)
                  XmlHttpRequest onprogress interval(XmlHttpRequest onprogress 間隔)
                  <i id='X1ZtT'><tr id='X1ZtT'><dt id='X1ZtT'><q id='X1ZtT'><span id='X1ZtT'><b id='X1ZtT'><form id='X1ZtT'><ins id='X1ZtT'></ins><ul id='X1ZtT'></ul><sub id='X1ZtT'></sub></form><legend id='X1ZtT'></legend><bdo id='X1ZtT'><pre id='X1ZtT'><center id='X1ZtT'></center></pre></bdo></b><th id='X1ZtT'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='X1ZtT'><tfoot id='X1ZtT'></tfoot><dl id='X1ZtT'><fieldset id='X1ZtT'></fieldset></dl></div>
                • <tfoot id='X1ZtT'></tfoot>

                      • <legend id='X1ZtT'><style id='X1ZtT'><dir id='X1ZtT'><q id='X1ZtT'></q></dir></style></legend>

                            <tbody id='X1ZtT'></tbody>
                            <bdo id='X1ZtT'></bdo><ul id='X1ZtT'></ul>
                          • <small id='X1ZtT'></small><noframes id='X1ZtT'>

                          • 主站蜘蛛池模板: 亚洲一二三视频 | 中文字幕亚洲一区 | 人人干在线 | 日本免费黄色 | 一区二区免费 | 一区二区三区在线播放 | 欧美 日韩 国产 一区 | 国产主播第一页 | 亚洲精品久 | 伊人网站在线观看 | 国产特级毛片 | 久久精品国产99国产 | 91久久精品一区二区二区 | 91久久电影 | 亚洲精品乱码 | 免费激情网站 | 91精品久久久久久久久久入口 | 久久精品男人的天堂 | 激情六月丁香 | 国产一区二区三区在线看 | 欧美激情精品久久久久久变态 | 国产一级电影在线 | 国产一区二区三区四区在线观看 | 黄色成人亚洲 | 91精品国产综合久久婷婷香蕉 | 91在线电影| 日韩成人精品在线 | 日韩成人免费视频 | 亚洲最新在线视频 | www.一区二区 | 国产综合欧美 | 韩日av在线 | 欧美精品在线播放 | 中文在线www | 一级毛片免费视频 | 亚洲国产成人精品久久久国产成人一区 | 亚洲国产成人在线视频 | 国产精品久久久久久婷婷天堂 | 欧美日韩福利 | 亚洲一区二区国产 | 成人一区二区视频 |