简体   繁体   English

XML HTTP响应问题:XML解析错误:找不到元素位置:moz-nullprincipal

[英]XML HTTP RESPONSE ISSUE : XML Parsing Error: no element found Location: moz-nullprincipal

Following is the Java Script code i have. 以下是我拥有的Java Script代码。

//URL = http://dev.stage.com/restapi/vc/auth/sessions/login/
//parametersURL = user.login=******&user.password=******
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlHttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }

xmlHttp.open( "POST", URL, true );
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlHttp.setRequestHeader("Content-length", parametersURL.length);
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(parametersURL);
xmlHttp.onreadystatechange = function() {//Call a function when the state changes.
if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
        alert(xmlHttp.responseText);
        return xmlHttp.responseXML;
    }
}

When tested in IE8, i am getting the correct response in the alert box. 在IE8中进行测试时,我在警报框中得到了正确的响应。

<response status="success"><value type="string">
uX-DjjZ2XrSB_GAfjSLTapOJvyvd2U9Y8MHsQzrvFeo.</value></response>

But when tested in Chrome and Firefox. 但是在Chrome和Firefox中进行测试时。 The response is empty. 响应为空。 When checked with FireBug the response is empty and in the XML I get the following error 当使用FireBug检查时,响应为空,并且在XML中出现以下错误

XML Parsing Error: no element found Location: moz-nullprincipal:{9fc08684-36c5-42b2-
b641-e9400c6e627f} Line Number 1, Column 1:

Using Poster plugin in Firefox i can get the correct response. 在Firefox中使用海报插件可以得到正确的响应。

Please, let me know what is the issue 请让我知道是什么问题

It is the cross domain issue. 这是跨域问题。 Which is not handled correctly in IE and hence it worked. 这在IE中无法正确处理,因此可以正常工作。 Use jsonp to make cross domain requests and it worked like a charm. 使用jsonp发出跨域请求,它的工作就像一个魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM