ajax Post提交问题

leisunzhi 2010-12-08 04:40:02
<script type="text/javascript">
var xmlHttp;
function CreateXMLHttpObject()
{
if(window.ActiveXObject)
{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xmlHttp = new XMLHttpRequest();
}
}

function CallBack()
{
if(xmlHttp.readyState == 4)
{
if(xmlHttp.status == 200)
{
var addresult = xmlHttp.responseText;
if(xmlHttp.responseText != "")
{
alert(addresult);
}
else
{

}
}
}
}

function Show()
{
var name;
CreateXMLHttpObject();
var url = "AjaxPostSave.aspx";
var postData= "content=" + name;
name=document.getElementById("txtSearch").value;
xmlHttp.onreadystatechange = CallBack;
xmlHttp.open("post",url,true);
xmlHttp.setRequestHeader("Content-Type","pplication/x-www-form-urlencoded")
xmlHttp.send("postData");
}
</script>
</head>
<body>
<form id="form1">
<div>
<input type="text" id="txtSearch" value="222"/><input type="button" value="搜索" onclick="Show()"/>
</div>
</form>
</body>
</html>
这是我的代码 我在另一个页面怎么获取不到值啊 Request.Form["content"]、Request.QueryString["content"] 都是空值???
...全文
125 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
flyerwing 2010-12-10
  • 打赏
  • 举报
回复
pplication
这个是错了
licip 2010-12-10
  • 打赏
  • 举报
回复
xmlHttp.setRequestHeader("Content-Type","pplication/x-www-form-urlencoded")
这个写错了吧。
应该是:
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
leisunzhi 2010-12-10
  • 打赏
  • 举报
回复
Request.Prams也获取不到
hoojo 2010-12-10
  • 打赏
  • 举报
回复
xmlHttp.setRequestHeader("Content-Type","pplication/x-www-form-urlencoded")
===>>>
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")

xmlHttp.send("postData");
==>>>
xmlHttp.send(postData);
leisunzhi 2010-12-09
  • 打赏
  • 举报
回复
我试过Request.Prams这个了
hch126163 2010-12-08
  • 打赏
  • 举报
回复
Request.Prams
十一文 2010-12-08
  • 打赏
  • 举报
回复
你这个不是post吧
Request["content"]
Request["content"]
获取哈看看

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧