<body> <form id="form1" runat="server"> <div > <button onclick="talktoServer('ajax.aspx')">提交给aj
functiontalktoServer(url){varreq=newXMLHTTPRequest();varcallbackHander=getReadyStateH...
function talktoServer(url)
{ var req=newXMLHTTPRequest();
var callbackHander=getReadyStateHandler(req);
req.open("POST",url,true);
req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
var testmsg=document.getElementById("testmsg");
var msg_value=testmsg.value;
req.send("msg="+msg_value);
}
//这是创建一个xmlhttp对象。。function newXMLHTTPRequest(){}
function getReadyStateHandler(req)
{return function() {if (req.readyState==4){ if (req.status==200){var msg_display=document.getElementById("msg_display");
msg_display.innerHTML=req.responseText;
}
else
{ // var hellomsg=docum }
}}}
总是出缺少对象的错误。 展开
{ var req=newXMLHTTPRequest();
var callbackHander=getReadyStateHandler(req);
req.open("POST",url,true);
req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
var testmsg=document.getElementById("testmsg");
var msg_value=testmsg.value;
req.send("msg="+msg_value);
}
//这是创建一个xmlhttp对象。。function newXMLHTTPRequest(){}
function getReadyStateHandler(req)
{return function() {if (req.readyState==4){ if (req.status==200){var msg_display=document.getElementById("msg_display");
msg_display.innerHTML=req.responseText;
}
else
{ // var hellomsg=docum }
}}}
总是出缺少对象的错误。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询