<tfoot id='GFpcM'></tfoot>

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

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

        <legend id='GFpcM'><style id='GFpcM'><dir id='GFpcM'><q id='GFpcM'></q></dir></style></legend>

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

        来自 XMLHttpRequest 的空 responseText

        时间:2023-10-15
      2. <tfoot id='SLIB4'></tfoot>
          <tbody id='SLIB4'></tbody>

          <legend id='SLIB4'><style id='SLIB4'><dir id='SLIB4'><q id='SLIB4'></q></dir></style></legend>
            <bdo id='SLIB4'></bdo><ul id='SLIB4'></ul>
          • <small id='SLIB4'></small><noframes id='SLIB4'>

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

                1. 本文介绍了来自 XMLHttpRequest 的空 responseText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我写了一个 XMLHttpRequest,它运行良好但返回一个空的 responseText.

                  I have written an XMLHttpRequest which runs fine but returns an empty responseText.

                  javascript如下:

                  The javascript is as follows:

                    var anUrl = "http://api.xxx.com/rates/csv/rates.txt";
                    var myRequest = new XMLHttpRequest();
                  
                    callAjax(anUrl);
                  
                    function callAjax(url) {
                       myRequest.open("GET", url, true);
                       myRequest.onreadystatechange = responseAjax;
                                   myRequest.setRequestHeader("Cache-Control", "no-cache");
                       myRequest.send(null);
                    }
                  
                    function responseAjax() {
                       if(myRequest.readyState == 4) {
                          if(myRequest.status == 200) {
                              result = myRequest.responseText;
                              alert(result);
                              alert("we made it");
                          } else {
                              alert( " An error has occurred: " + myRequest.statusText);
                          }
                       }
                    }
                  

                  代码运行良好.我可以走过去,我得到了 readyState == 4 和一个状态 == 200 但 responseText 总是空白.

                  The code runs fine. I can walk through and I get the readyState == 4 and a status == 200 but the responseText is always blank.

                  我收到错误调度的日志错误(在 Safari 调试中):getProperties,我似乎无法找到参考.

                  I am getting a log error (in Safari debug) of Error dispatching: getProperties which I cannot seem to find reference to.

                  我已经在本地和远程服务器上的 Safari 和 Firefox 中运行了代码.

                  I have run the code in Safari and Firefox both locally and on a remote server.

                  将 URL 放入浏览器时将返回字符串并给出状态码 200.

                  The URL when put into a browser will return the string and give a status code of 200.

                  我在一个运行良好的 Mac Widget 中为相同的 URL 编写了类似的代码,但在浏览器中的相同代码永远不会返回结果.

                  I wrote similar code to the same URL in a Mac Widget which runs fine, but the same code in a browser never returns a result.

                  推荐答案

                  http://api.xxx.com/ 是否属于您的域?如果没有,您将被同源政策阻止.

                  Is http://api.xxx.com/ part of your domain? If not, you are being blocked by the same origin policy.

                  您可能需要查看以下 Stack Overflow 帖子,了解一些可能的解决方法:

                  You may want to check out the following Stack Overflow post for a few possible workarounds:

                  • 规避同源策略的方法

                  这篇关于来自 XMLHttpRequest 的空 responseText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 IE 中从 Javascript 访问 XHR responseBody(用于二 下一篇:我如何知道 jQuery 是否有待处理的 Ajax 请求?

                  相关文章

                  最新文章

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

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

                  4. <legend id='Jz3nZ'><style id='Jz3nZ'><dir id='Jz3nZ'><q id='Jz3nZ'></q></dir></style></legend>
                    • <bdo id='Jz3nZ'></bdo><ul id='Jz3nZ'></ul>