比如各自传送一个数据1到test.jsp 他们的写法是???? 我对get还了解一些 没用过post发送
这是get方式,post方式不会写var xmlhttp;
if(window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
xmlhttp=new XMLHttpRequest();
}
function senddata()
{
serverpage="test.jsp?data=1";
xmlhttp.open("GET",serverpage);
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4&&xmlhttp.status==200)
{
document.getElementById("msg").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.send(null);
}
这是get方式,post方式不会写var xmlhttp;
if(window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
xmlhttp=new XMLHttpRequest();
}
function senddata()
{
serverpage="test.jsp?data=1";
xmlhttp.open("GET",serverpage);
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4&&xmlhttp.status==200)
{
document.getElementById("msg").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.send(null);
}
解决方案 »
- 用Javascript 对IE 的WEB打印进行控制
- 这个js传值为什么不对 求高手 解 急在线等
- 这段代码什么意思。。怎么调用??
- 20080214 两颗星星一个人,希望三颗星时两个人,啥都不说了,照例散分~~~
- 怎样可以查看指定页的客户端源代码?
- 请教星级高手:如何在asp程序中修改IE中默认的键值?
- 如何让ifame里输入文字后,自动换行?
- 将字符串“aa”转成对象变量怎么做?用哪个函数 在ASP中又如何做呢!谢谢
- 如何做到当我录入是一篇带有html标记的文本(如需要强调的内容显示为红色,作个联接等等)。输出是为按照html 的方式输出
- 相同的事件,如何连写,谢谢
- 能不能刷新一个页面时 让其显示指定位置
- 您好,帮忙看下代码如何?
xmlhttp.open("Post",url);
var xmlhttp;
if(window.ActiveXObject)
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
xmlhttp=new XMLHttpRequest();
}
function senddata()
{
serverpage="test.jsp";
data = 'data=1'
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4&&xmlhttp.status==200)
{
document.getElementById("msg").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("POST",serverpage);
xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;');
xmlhttp.send(data);
}
楼主 试试