使用ajax回传服务器时间出错
就是用ajax回传服务器时间,调试过了,但是就是点击按钮没有反应,是哪里错了????
代码如下:
<script type="text/javascript" language="javascript">
var request=false;
function createXMLHttp()//实例化xmlhttp对象
{
try
{
request= new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e1)
{
try
{
request=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e2)
{
request=false;
}
}
if(request==false&&typeof XMLHttpRequest!="undefined")
{
request=new XMLHttpRequest();
}
return request;
}
function getTime(format)//触发提交函数
{
createXMLHttp();
var url ="ServerTime.aspx?format=" + format;
request.open("Get",url,true);
request.onreadystatechange=update;
request.send(null);
}
function update()
{
if(request.readyState==4&&request.state==200)
document.getElementById("d1").innerHTML=request.responseText;
}
</script>
</head>
<body>
<table>
<tr><td>服务器时间:</td><td><div id="d1">
</div></td></tr>
<tr><td>
<input id="btnTime" type="button" value="获取时间" onclick="javascript:void getTime("HH-mm-ss")" /></td>
<td><input id="btnDate" type="button" value="获取日期" onclick="javascript:void getTime("yyyy-MM-dd")"/></td>
</tr>
</table>
</bo