Ajax使用Post方法传递数据
function JugingData()
{
var xmlHttp;
try
{
xmlHttp = new XMLHttpRequest();
}
catch(e)
{
try
{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
xmlHttp = new ActiveXObject ("Microsoft.XMLHTTP");
}
catch(e)
{
alert("您的浏览器不支持Ajax!");
return false;
}
}
}
xmlHttp .open("post","JugeOutPutAvalable.aspx",true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp .onreadystatechange = function()
{
if (xmlHttp.readyState == 4)
{
var strResult = xmlHttp .responseText;
alert(strResult);
}
}
xmlHttp .send("Datas=大量的数据");
}
本人具体也没研究过为什么要加上这句话(不加是不能使用的):
request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
浙公网安备 33010602011771号