可能重复:
get values on server-side sent with xmlHttp.open(GET
Get value from AJAX using Javascript and ASP
我在客户端ASP javascript上有两个值(数字),我想发送到服务器端的asp javascript。 所以我的代码是这样的:(客户端)
function receiveResult(_data,nbquestions)
{
//alert(nbquestions)
//alert(_data)
var xmlHttp;
try
{
/* Firefox, opera */
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
/* IE 9 */
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
/* IE 6.x-8*/
try
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
alert("Your browser is old please update it !");
return false ;
}
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
/* this puts the value into an alert */
}
}
// send querystring to the server-side
xmlHttp.open("post","CmsAjax.asp",true)
xmlHttp.send("param1="+_data+"¶m2="+nbquestions);
}
我有两个问题:
xmlHttp.send是否正确写入?
如何使用JavaScript获取服务器端的值?