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

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

        <bdo id='mxy96'></bdo><ul id='mxy96'></ul>
    1. XMLHTTPRequest.status 在 FireFox 3.5 中返回 0 并且 resp

      时间:2023-10-14
      • <bdo id='a6g5U'></bdo><ul id='a6g5U'></ul>

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

            <tbody id='a6g5U'></tbody>

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

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

                本文介绍了XMLHTTPRequest.status 在 FireFox 3.5 中返回 0 并且 responseText 为空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在尝试访问第三方 URL 以获取 XML 响应并将响应显示到我的网页中.在 IE 和 Safari 浏览器中,我得到了状态为 200 和 readystate 为 4 的正确响应.但在 FF3.5 和 Crome 中,我将 XMLHTTPRequest 状态设为 0,而 reponseText 以空白字符串的形式出现.我尝试了许多选项来编写普通的 XMLHTTPRequest Ajax 代码以及为此 ajax 请求使用 Prototype 1.5 版本的 js 文件,但 FF 3.5 中的状态和响应文本仍然与 0 和空白字符串相同.

                I am trying to hit a third party URL to get the XML response and to show the reposne into my webpage. I get a proper response with status as 200 and readystate as 4 in IE and Safari browsers. But In FF3.5 and Crome i get XMLHTTPRequest status as 0 and reponseText comes as a blank string. I tried many options writing the normal XMLHTTPRequest Ajax code as well as using Prototype 1.5 version js file for this ajax request, but still the status and reponseText in FF 3.5 remains the same as 0 and blank string.

                任何帮助如何解决此问题或导致此问题的确切原因将不胜感激.我还尝试在本地执行我的代码以及部署到网络服务器,但 FF 中的响应是相同的.

                Any help how to resolve this issue or what exactly is causing this issue would be greatly appreciated. I had also tried to execute my code locally as well as deploying to webserver still the repsonse in FF is same.

                下面是我的代码片段

                <script type="text/javascript" src="prototype_ajax.js"></script>
                
                <script type="text/javascript" language="javascript">
                
                new Ajax.Request("I place my URL Here", {
                    method: 'get',
                    onSuccess : function(transport){
                
                       var resultDoc = transport.responseText;
                       var rootObj = loadXML(resultDoc);
                
                    },
                    onFailure : function(transport){
                       alert(' On Failure '+transport)
                
                    }
                });
                
                function loadXML(xmlFile) {
                   var xmlDocElement =null;
                   var xmlDoc = null;
                
                   if (window.ActiveXObject) {
                     try {
                        // code for IE
                        xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
                        xmlDoc.async=false;
                        xmlDoc.loadXML(xmlFile);
                     } catch (e) {
                        alert("inside catch::"+e.message);
                     }
                   } else {
                     // code for Mozilla, Firefox, Opera, etc.
                     parser=new DOMParser();
                     xmlDoc=parser.parseFromString(xmlFile,"text/xml");
                
                     //xmlDocElement=xmlDoc.documentElement;
                   }
                
                   //alert('loadXML value  '+xmlDoc)
                   return xmlDoc;
                }
                
                </script>
                

                推荐答案

                你好像碰到了 同源政策.您必须使用相对路径,否则大多数浏览器只会返回一个空的 responseText.

                It looks like you have bumped into the same origin policy. You have to use a relative path, otherwise most browsers will simply return an empty responseText.

                以下 Stack Overflow 帖子可能也与您的问题有关:

                The following Stack Overflow post is probably also related to your problem:

                • XMLHttpRequest 中的空响应文本.

                作为一种可能的解决方法,您可以设置一个非常简单的反向代理(使用 mod_proxy 如果您使用的是 Apache).这将允许您在 AJAX 请求中使用相对路径,而 HTTP 服务器将充当任何远程"位置的代理.

                As one possible workaround, you could set up a very simple reverse proxy (with mod_proxy if you are using Apache). This would allow you to use relative paths in your AJAX request, while the HTTP server would be acting as a proxy to any "remote" location.

                在 mod_proxy 中设置反向代理的基本配置指令是 ProxyPass.您通常会按如下方式使用它:

                The fundamental configuration directive to set up a reverse proxy in mod_proxy is the ProxyPass. You would typically use it as follows:

                ProxyPass     /web-services/     http://third-party.com/web-services/
                

                在这种情况下,浏览器将请求 /web-services/service.xml,但服务器将通过充当 http://third-party 的代理来提供此服务.com/web-services/service.xml.

                In this case, the browser would be requesting /web-services/service.xml but the server would serve this by acting as a proxy to http://third-party.com/web-services/service.xml.

                这篇关于XMLHTTPRequest.status 在 FireFox 3.5 中返回 0 并且 responseText 为空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:为什么我的 XHR 的 statusText 是空的? 下一篇:XMLHttpRequest Post 上的 send() 数据参数的最大长度

                相关文章

                最新文章

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

                <small id='4YB1D'></small><noframes id='4YB1D'>

                1. <tfoot id='4YB1D'></tfoot>
                2. <legend id='4YB1D'><style id='4YB1D'><dir id='4YB1D'><q id='4YB1D'></q></dir></style></legend>
                    • <bdo id='4YB1D'></bdo><ul id='4YB1D'></ul>