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

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

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

      <tfoot id='Q1exD'></tfoot>
        • <bdo id='Q1exD'></bdo><ul id='Q1exD'></ul>

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

      1. 捕獲 XMLHttpRequest 跨域錯誤

        Catching XMLHttpRequest cross-domain errors(捕獲 XMLHttpRequest 跨域錯誤)
          <bdo id='86y7X'></bdo><ul id='86y7X'></ul>

          <small id='86y7X'></small><noframes id='86y7X'>

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

                    <tbody id='86y7X'></tbody>
                  <tfoot id='86y7X'></tfoot>

                  本文介紹了捕獲 XMLHttpRequest 跨域錯誤的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  有什么方法可以在發出請求時捕獲由 Access-Control-Allow-Origin 引起的錯誤?我正在使用 jQuery,并且在 .ajaxError() 中設置的處理程序永遠不會被調用,因為請求永遠不會開始.

                  Is there any way to catch an error caused by Access-Control-Allow-Origin when making a request? I'm using jQuery, and the handler set in .ajaxError() never gets called because the request is never made to begin with.

                  有什么解決辦法嗎?

                  推薦答案

                  對于 CORS 請求,應該觸發 XmlHttpRequest 的 onError 處理程序.如果您有權訪問原始 XmlHttpRequest 對象,請嘗試設置事件處理程序,例如:

                  For CORS requests, the XmlHttpRequest's onError handler should fire. If you have access to the raw XmlHttpRequest object, try setting an event handler like:

                  function createCORSRequest(method, url){
                    var xhr = new XMLHttpRequest();
                    if ("withCredentials" in xhr){
                      xhr.open(method, url, true);
                    } else if (typeof XDomainRequest != "undefined"){
                      xhr = new XDomainRequest();
                      xhr.open(method, url);
                    } else {
                      xhr = null;
                    }
                    return xhr;
                  }
                  
                  var url = 'YOUR URL HERE';
                  var xhr = createCORSRequest('GET', url);
                  xhr.onerror = function() { alert('error'); };
                  xhr.onload = function() { alert('success'); };
                  xhr.send();
                  

                  注意幾點:

                  • 在 CORS 請求中,瀏覽器的 console.log 將顯示一條錯誤消息.但是,您的 JavaScript 代碼無法使用該錯誤消息(我認為這是出于安全原因,我之前曾問過這個問題:是否可以捕獲 CORS 錯誤?).

                  xhr.status 和 xhr.statusText 沒有在 onError 處理程序中設置,因此對于 CORS 請求失敗的原因,您并沒有任何有用的信息.你只知道它失敗了.

                  The xhr.status and xhr.statusText aren't set in the onError handler, so you don't really have any useful information as to why the CORS request failed. You only know that it failed.

                  這篇關于捕獲 XMLHttpRequest 跨域錯誤的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  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 部分內容)

                        <tbody id='eRZzi'></tbody>
                          <tfoot id='eRZzi'></tfoot>
                        • <small id='eRZzi'></small><noframes id='eRZzi'>

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

                          • 主站蜘蛛池模板: 欧美在线视频一区 | 人人人干| 在线观看亚洲精品视频 | 日本网站免费在线观看 | 天天在线操| 成人小视频在线观看 | 天堂成人av | 一区二区三区中文字幕 | 天天插天天操 | 亚洲欧美日韩精品久久亚洲区 | 91视视频在线观看入口直接观看 | 欧美福利久久 | 亚洲国产第一页 | 精品国产一区二区三区av片 | 国产91久久久久久 | 日韩国产精品一区二区三区 | 日韩高清国产一区在线 | 精品久久久久久久久久久久久久 | 精品综合 | 亚洲久久一区 | 三级成人在线 | 正在播放国产精品 | 中文字幕一区在线观看视频 | 暖暖成人免费视频 | 久久成人综合 | 免费网站在线 | 亚洲最色视频 | 91观看| 中文字幕视频网 | 国精产品一品二品国精在线观看 | 日韩一级黄色片 | 日日噜噜噜夜夜爽爽狠狠视频, | 亚洲国产欧美在线人成 | 亚洲一区综合 | www.精品一区 | 黑人巨大精品欧美一区二区免费 | 涩涩视频网站在线观看 | 免费一级欧美在线观看视频 | 国产成人一区在线 | 欧美日韩成人影院 | 国产探花 |