Yat*_*tin 5 xml ajax web-services xmlhttprequest
function sendPost(){
alert("IN SEND POST");
var username = document.myForm.username.value;
var password = document.myForm.password.value;
alert("username"+username);
alert("password"+password);
console.log("in java script");
var url = "some url";
alert("IN url SEND POST");
var data = "<MESSAGE><HEADER><LOGIN>005693</LOGIN></HEADER><SESSION><LATITUDE>0.0</LATITUDE><LONGITUDE>0.0</LONGITUDE><APP>SRO</APP><ORG>MNM</ORG><TRANSACTION>PRELOGIN</TRANSACTION><KEY>PRELOGIN/ID</KEY><TYPE>PRELOGIN</TYPE></SESSION><PAYLOAD><PRELOGIN><ID>005693</ID><USERNAME>005693</USERNAME><PASSWORD>tech@2014</PASSWORD></PRELOGIN></PAYLOAD></MESSAGE>";
console.log("2")
var req;
if(window.XMLHttpRequest) {
console.log("2");
try {
req = new XMLHttpRequest();
} catch(e) {
req = false;
}
}
else if(window.ActiveXObject) {
console.log("3");
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
req = false;
}
}
}
console.log("4");
req.onreadystatechange=function()
{
console.log("5");
if (req.readyState==4 && req.status==200)
{
console.log("ready state accepted");
xmlDoc=req.responseXML;
console.log("xmlDoc"+xmlDoc);
alert("xmlDoc"+xmlDoc);
txt="";
x=xmlDoc.getElementsByTagName("FIRSTNAME");
y=xmlDoc.getElementsByTagName("LASTNAME");
console.log("Response achieved"+x);
}
}
req.open("POST",url,true);
console.log("6");
req.setRequestHeader("Content-type","application/xml");
req.send(data);
console.log("7");
return true;
}
Run Code Online (Sandbox Code Playgroud)
我完全像我想要的那样在休息客户端得到回应
在Google Chrome中 - >我的状态为0,就绪状态为1,然后是4在Internet Explorer中 - >我的状态为200 OK,就绪状态为1,2,3,4,但返回空白xml
在休息客户端,我得到一个完美的命中,并返回一个xml
我尝试用不同的方式提问,但有些人说它是一个交叉起源的问题如果是的话请通过javascript中的代码知道解决方案
请指导

服务器表示它正在发送text/plain数据,而不是 XML,因此浏览器不会填充req.responseXML. 数据应该在req.responseText.
| 归档时间: |
|
| 查看次数: |
2688 次 |
| 最近记录: |