我做了一个按钮,当按下它带来服务器时间,,,所以有这个html和js文件,我希望它从time.tcl文件中获取时间,请帮助我:
1.my使用html和Javascript文件:
<html>
<body>
<input value="Get Time" type="button" onclick='JavaScript:showCurrentTime()' name="GetTime">
<div id="result" align="center"></div>
<script language="Javascript">
function showCurrentTime()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
var xmlhttp;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5
xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”);}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("result").innerHTML=xmlhttp.responseText;
}
xmlhttp.open(“GET”,”time.tcl”,true);
</script>
</body>
</html>
2.my time.tcl文件:
set now [clock seconds]
# print default-formatted time
puts [clock format $now]
# print custom formatted time
set fmt "Today is day %j of the current year."
puts [clock format $now -format $fmt]
set today [clock seconds]
set fmt "%Y-%m-%d"
puts "The current date is [clock format $today -format $fmt]."
答案 0 :(得分:0)
我不认为开放函数中的这些引号“ ”
是有效的,语义
您是否尝试过更换
xmlhttp.open(“GET”,”time.tcl”,true);
带
xmlhttp.open("GET","time.tcl",true);