ajax传输时数据长度受限制,请帮忙!

来源:百度知道 编辑:UC知道 时间:2024/05/25 12:44:29
我想用这一段代码传一篇文章,但这样传受字数限制,怎么样解决这个问题?最好能详细一点.
var xmlhttp;
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.Open("post","day_clear_print_formnew.asp?tcontent="+sender.innerText+"&twork="+wk+"&ttime="+dt+"&sh="+sh,false);
try{ xmlhttp.Send();}
catch(e){}
if(xmlhttp.responseText=='')
{
alert('数据保存失败!');
return false;
}
else
{
document.all.aaa.innerHTML=xmlhttp.responseText;
}
请写详细一点可以吗?ajax我不是很熟悉.最好全部写出来,我再加20分

你这个明显还是get方式传递的嘛,不能在url里,那个是有长度限制的
改成这样
xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
var body="tcontent="+encodeURIComponent(sender.innerText);
xmlhttp.open("post","day_clear_print_formnew.asp?twork="+wk+"&ttime="+dt+"&sh="+sh,false);
xmlhttp.send(body);
服务端要接收post的数据。