日期:2014-05-16  浏览次数:20671 次

服务器端如何读取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对象,然后加载这个片段解析;也可以直接用正则解吸;当然也可以直接作为普通串用常规方法解析.