js+ajax返回的结果有问题,求教!!!
页面代码:
function startRequest()
{
createXMLHttpRequest();
xmlHttp.open("GET","Default2.aspx?_czlx=mylove",true);
xmlHttp.onreadystatechange = handleStateChange;
xmlHttp.send(null);
}
function handleStateChange()
{
if(xmlHttp.readyState==4)
{
if(xmlHttp.status==200)
{
alert(xmlHttp.responseText);
}
}
}
Default2.aspx代码:
protected void Page_Load(object sender, EventArgs e)
{
string aa = Request.QueryString["_czlx"];
Response.Write(aa.ToString());
}
向Default2.aspx中传字符串并得到返回值;
结果为如下,还带出了网页文本,为什么呀???
mylove
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title> 无标题页</title>
</head>
<body>
<form name="form1" method="post" action="Default2.aspx?_czlx=mylove" id="form1"><div><input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGRQNhbM5Sr1n8X06EMReNBlo8bVHg==" /></div>
<div>
</div>
</form>
</body>
</html>
------解决方案--------------------Response.AddHeader("content-type","text/html");
------解决方案--------------------Response.Clear();
Response.Write(aa.ToString());
Response.End();