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

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

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

      1. 来自 XMLHttpRequest 的空 responseText

        时间:2023-05-16
            <tbody id='ERQPJ'></tbody>
          <i id='ERQPJ'><tr id='ERQPJ'><dt id='ERQPJ'><q id='ERQPJ'><span id='ERQPJ'><b id='ERQPJ'><form id='ERQPJ'><ins id='ERQPJ'></ins><ul id='ERQPJ'></ul><sub id='ERQPJ'></sub></form><legend id='ERQPJ'></legend><bdo id='ERQPJ'><pre id='ERQPJ'><center id='ERQPJ'></center></pre></bdo></b><th id='ERQPJ'></th></span></q></dt></tr></i><div id='ERQPJ'><tfoot id='ERQPJ'></tfoot><dl id='ERQPJ'><fieldset id='ERQPJ'></fieldset></dl></div>
            <bdo id='ERQPJ'></bdo><ul id='ERQPJ'></ul>
            <tfoot id='ERQPJ'></tfoot>

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

                • <small id='ERQPJ'></small><noframes id='ERQPJ'>

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

                  问题描述

                  限时送ChatGPT账号..

                  我写了一个 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文章

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

                      <bdo id='X9vTx'></bdo><ul id='X9vTx'></ul>
                  1. <legend id='X9vTx'><style id='X9vTx'><dir id='X9vTx'><q id='X9vTx'></q></dir></style></legend>

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

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