读书人

服务器端怎么读取XML请求

发布时间: 2012-02-06 15:52:44 作者: rapoo

服务器端如何读取XML请求 - Web 开发 / Ajax
.JS文件,我该在服务器端如何接收到userID这个值,急!!!!! 在线等

var userID = document.getElementById("txtID").value;

var xmlString = "<profile>" +
"<userID>" + escape(userID) + "</userID>" +
"</profile>";

// Build the URL to connect to
var url = "TempXMLRequest.aspx";

// Open a connection to the server
xmlHttp.open("POST", url, true);

// Tell the server you're sending it XML
xmlHttp.setRequestHeader("Content-Type", "text/xml");

// Set up a function for the server to run when it's done
xmlHttp.onreadystatechange = confirmUpdate;

// Send the request
alert(xmlString);
xmlHttp.send(xmlString);


[解决办法]
再封装一次
xmlString = "xml="+xmlString
然后发送,后台request("xml")接着在服务器端建立一个xml对象,然后加载这个片段解析;也可以直接用正则解吸;当然也可以直接作为普通串用常规方法解析.

读书人网 >Ajax

热点推荐