给你段ajax的代码,你自己重新改成你想要的形式,别说的我给的是垃圾代码啊!:)
<script>
var xhtp
function fresh1()
{
if(window.ActiveXObject)
{
xhtp=new ActiveXObject("Microsoft.XMLHTTP");
}
else if(window.XMLHttpRequest)
{
xhtp=new XMLHttpRequest();
}
var url=document.getElementById("url").value;
xhtp.open("GET","http://localhost:9191/TestXML/ajax1","true");//建立连接
xhtp.send(null);//发送请求
if(xhtp.readystate==4)//判断连接状态
{
if(xhtp.status==200)//返回是否正确
{
//alert("eeeeeee");
var mes=xhtp.responseText;//获得返回值
//alert(mes);
document.getElementById("url2").value=mes;
document.forms[0].submit();
}
}
function fresh(){
setTimeout("fresh1",2000)
}
}
</script>