xmlHttpRequest.open("GET","hello.hello",true);
hello.hello 是什么?url?
xmlHttpRequest.setRequestHeader("Content-Type","application/soap+xml; charset=utf-8");
这个头将会破坏服务端对传入数据的解析
xmlHttpRequest.send(xmlDocI);
只有 post 方式才会发送参数,get 方式是不会发送的
hello.hello 是什么?url?
xmlHttpRequest.setRequestHeader("Content-Type","application/soap+xml; charset=utf-8");
这个头将会破坏服务端对传入数据的解析
xmlHttpRequest.send(xmlDocI);
只有 post 方式才会发送参数,get 方式是不会发送的
解决方案 »
- 求教一个正则匹配的问题
- javascript + Ajax 跨页取值 同样alert 弹出不同值
- js或者jQuery的问题
- asp.net中javascript执行顺序问题
- 请问javascript传递参数的问题
- 关于alert的问题,挺急,请大家帮个忙
- ***在用window.open和window.showModelessDialog方法弹出的页面中,ActiveX控件的所有事件竟然不触发,window.showModalDialog方式却是可
- 有谁作过在WEB上的新建或已存在的OFFICE 文档,经客户修改后发回服务器,有高分
- 关于跨FRAME操作的问题,请大家帮忙。
- jquery验证只能输入英文
- 了解ext.js的来看看
- JS 图片尺寸压缩,请教
xmlDoc.load(url);
return(xmlDoc);你直接返回xmldom,ajax的send方法是不会自动序列化为xml字符串的,会调用toString方法返回对象名称,你要自己序列化为xml字符串
if(xmlDoc.xml)return xmlDoc.xml;//IE
if(window.XMLSerializer)return new window.XMLSerializer().serializeToString(xmlDoc);
alert('无法序列化xmldom');
hello.hello 是我自己定义的,服务那边可以识别。问题还没有解决,麻烦两位版主再指导指导!
xmlDocI=loadXMLDoc(url);
str=XML2String(xmlDocI);
document.getElementById("a").innerHTML=str;//convert xml object to string
function XML2String(xmlObject)
{
// for IE
if (window.ActiveXObject)
{
return xmlObject.xml;
}
// for other browsers
else
{
return (new XMLSerializer()).serializeToString(xmlObject);
}
} 以上程序显示str为: 1.0 3.0 。 这并不是我预期的结果,我希望通过
xmlHttpRequest.send(str)把calc.add.req.xml数据作为http content发送出去。另外,我调用 xmlHttpRequest.send("hello world!"), 也没有发现"hello world!"被发送出去!! 哪里的问题呢??
calc.add.req.xml文件如下:<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://www.w3.org/2003/05/soap-envelope"
xmlns:SOAP-ENC="http://www.w3.org/2003/05/soap-encoding"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns2="urn:calc">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<ns2:add>
<a>1.0</a>
<b>3.0</b>
</ns2:add>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
只有 post 方式才会发送参数,get 方式是不会发送的
xmlDocI = loadXMLDoc(url); xmlHttpRequest = createXmlHttpRequest(); xmlHttpRequest.onreadystatechange = get_result; xmlHttpRequest.open("POST", "hello.hello", true);////////// xmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");/////// xmlHttpRequest.send(xmlDocI);
} function get_result() {
if (xmlHttpRequest.readyState == 4) {
if (xmlHttpRequest.status == 200) {
var response = xmlhttp.responseText;
document.getElementById("result").innerHTML = response;
}
}
}
function XML2String(xmlObject) {
// for IE
if (window.ActiveXObject) {
return xmlObject.xml;
}
// for other browsers
else {
return (new XMLSerializer()).serializeToString(xmlObject);
}
}
function loadXMLDoc(url) {
var xmlDoc;
try {
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
}
catch (e) {
try {
xmlDoc = document.implementation.createDocument("", "", null);
}
catch (e) { alert(e.message) }
}
try {
xmlDoc.async = false;
xmlDoc.load(url);
alert(XML2String(xmlDoc))///////////
return XML2String(xmlDoc);/////////////////////////////////
}
catch (e) { alert(e.message) }
return (null);
}