<script language="JavaScript">
function loadchild(result)
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var dom = new ActiveXObject("MSXML2.DOMDocument");
xmlhttp.open("POST","http://localhost/TestDB/MenuService.asmx/GetMenutest", false);
xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlhttp.setRequestHeader("Content-Length", "68");
xmlhttp.Send("");
var value = xmlhttp.responseText; alert(value);
//document.all.item(result).innerHTML = value;
}
</script>我在客户端是这么写的,可以获得整个页面的内容:
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="TestDB">abcdef</string> 如果我改成
xmlhttp.open("GET","http://localhost/TestDB/MenuService.asmx/GetMenutest", false);
就报错,为什么"get"不能使用
function loadchild(result)
{
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var dom = new ActiveXObject("MSXML2.DOMDocument");
xmlhttp.open("POST","http://localhost/TestDB/MenuService.asmx/GetMenutest", false);
xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlhttp.setRequestHeader("Content-Length", "68");
xmlhttp.Send("");
var value = xmlhttp.responseText; alert(value);
//document.all.item(result).innerHTML = value;
}
</script>我在客户端是这么写的,可以获得整个页面的内容:
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="TestDB">abcdef</string> 如果我改成
xmlhttp.open("GET","http://localhost/TestDB/MenuService.asmx/GetMenutest", false);
就报错,为什么"get"不能使用
<?xml version="1.0" encoding="utf-8" ?>
<string xmlns="TestDB">abcdef</string>
整个页面的内容,如何只要“abcdef”内容,即节点内的内容
用DOM解析即可
我写成这样
var childs=dom.documentElement.childNodes;
他不认
dom.loadXML(xmlhttp.responseText);var items = dom.selectNodes("//string");alert(items(0).xml);
var node_text = nodes[0].text;
alert(node_text);
第二个问题这样就可以了
,但是第一个问题,为什么改成"get"就不可以