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

    <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

        Empty responseText from XMLHttpRequest(来自 XMLHttpRequest 的空 responseText)
        <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>

                  <tbody id='GFpcM'></tbody>
                <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的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我写了一个 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模板网!

                  【网站声明】本站部分内容来源于互联网,旨在帮助大家更快的解决问题,如果有图片或者内容侵犯了您的权益,请联系我们删除处理,感谢您的支持!

                  相关文档推荐

                  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 部分内容)

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

                    • <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>
                    • <tfoot id='Jz3nZ'></tfoot>

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

                              <tbody id='Jz3nZ'></tbody>