注册 登录
编程论坛 jQuery论坛

[求助]xmlhttp.send 问题

xbdeig 发布于 2007-01-13 20:04, 2073 次点击
function ajaxSendPost(url, values, processRequest) {
ajaxHttpRequest.open("POST",url, true)
ajaxHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajaxHttpRequest.send(values);
ajaxHttpRequest.onreadystatechange = processRequest;
}
function Button1_onclick() {
ajaxInit()
ajaxSendPost("ajaxchat.aspx", "username=name", box);
}

为什么执行过后,Request["username"] 取不到值呀?

我所有代码都是在这页面执行的,ajaxchat.aspx
5 回复
#2
icecool2007-01-13 22:38
ajaxSendPost("ajaxchat.aspx", "username=name", box);

这里为何是这个样子呢?
#3
xbdeig2007-01-14 11:04
Request["username"] 值 就是name 呀
现在问题是值接受不到呀,先不管传的什么值了
#4
xbdeig2007-01-14 16:59

<script type="text/javascript">
var ajaxHttpRequest = false;

function ajaxInit() {
if(window.XMLHttpRequest) { //Mozilla, Opera, ...
ajaxHttpRequest = new XMLHttpRequest();
if(ajaxHttpRequest.overrideMimeType) {
ajaxHttpRequest.overrideMimeType("text/xml");
}
}
else if(window.ActiveXObject) { //IE
try{
ajaxHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try{
ajaxHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
}
}
}
if(!ajaxHttpRequest) {
alert("不能创建XMLHttpRequest对象实例");
return false;
}
else{alert("创建XMLHttpRequest对象实例");}
}
function ajaxSendPost(url, values, processRequest) {
ajaxHttpRequest.open("POST",url, true)
ajaxHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajaxHttpRequest.send(values);
ajaxHttpRequest.onreadystatechange = processRequest;
}
function Button1_onclick() {
ajaxInit()
ajaxSendPost("ajaxchat.aspx?username=aa","null", box);
}
function box(){
if(ajaxHttpRequest.readyState==4) {
if(ajaxHttpRequest.status==200) {
alert('Msg');
}
}
}
</script>
然后我在本页面代码里写 Response.Write(Request["username"]);
为什么什么都没有呀?Request["username"]根本没值
我新学ajax,帮帮我!

#5
xbdeig2007-01-14 18:23

获取到了,呵~不知道为什么。开心..

#6
nightheart2007-01-24 08:48
...楼主的SERVER是什么??
1