我在 php 中创建了一个井字游戏。我创建了以下代码来显示网格并将请求发送到 php-
<html>
<head>
<script type="text/javascript">
function showData(str)
{
if(str==""){
document.getElementById("showData").innerHTML="";
}
if(window.XMLHttpRequest){
//code for IE7+, Firefox, Chreom, 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("showData").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","tttoe?move="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<center>
<div id="showData">
<table border="1" cellpadding="1" cellspacing="1">
<tr>
<td> <input type="button" class="button1" name="move" value="1" onClick="showData(this.value)" /> </td>
<td> <input type="button" class="button1" name="move" value="2" onClick="showData(this.value)" /> </td>
<td> <input type="button" class="button1" name="move" value="3" onClick="showData(this.value)" /> </td>
</tr>
<tr>
<td> <input type="button" class="button1" name="move" value="4" onClick="showData(this.value)" /> </td>
<td> <input type="button" class="button1" name="move" value="5" onClick="showData(this.value)" /> </td>
<td> <input type="button" class="button1" name="move" value="6" onClick="showData(this.value)" /> </td>
</tr>
<tr>
<td> <input type="button" class="button1" name="move" value="7" onClick="showData(this.value)" /> </td>
<td> <input type="button" class="button1" name="move" value="8" onClick="showData(this.value)" /> </td>
<td> <input type="button" class="button1" name="move" value="9" onClick="showData(this.value)" /> </td>
</tr>
</table>
</div>
</center>
</body>
</html>
有没有办法让我可以显示一个文本(处理中.....)直到请求完成?