send()函数的问题
<script language=javascript>
var xmlHttp;
function CreateXMLHttpRequest()
{
if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("MicroSoft.XMLHTTP");
}
else
{
xmlHttp = new XMLHttpRequest();
}
}
function CreateXML()
{
var xml = "<pets>";
var options = document.getElementById("pettypes").childNodes;
var option = null;
for(var i = 0; i < options.length; i++)
{
option = options;
if (option.selected)
{
xml += "<type>"+ option.value +"</type>";
}
}
xml += "</pets>";
return xml;
}
function SendPetTypes()
{
CreateXMLHttpRequest();
var xml = CreateXML();
var url ="server.aspx?time="+ new Date().getTime();
xmlHttp.open("POST",url,true);
xmlHttp.onreadystatechange = HandleStateChange;
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(xml);
//********************************************
//好象这个地方有问题
//********************************************
}
function HandleStateChange()
{
if(xmlHttp.readyState == 4)
{
if (xmlHttp.status == 200)
{
//这里返回405
ParseResults();
}
}
}
function ParseResults()
{
var resultDiv = document.getElementById("resultDiv");
if (resultDiv.hasChildNodes())
{
resultDiv.removeChild(resultDiv.childNodes[0]);
}
var responseText = document.createTextNode(xmlHttp.responseText);
resultDiv.appendChild(responseText);
}
</script>
难道send函数不能直接传一个xml进去?
|