我有以下代码..
async function updateItems()
{
await fetch('http://127.0.0.1/WebProjects/LARPLookup/Actions/Game/Items.cfm')
.then(response => response.text())
.then((response) => {document.getElementById("nav-items").innerHTML = response;})
}
async function updateKnowledge()
{
await fetch('http://127.0.0.1/WebProjects/LARPLookup/Actions/Game/Knowledge.cfm')
.then(response => response.text())
.then((response) => {document.getElementById("nav-knowledge").innerHTML = response;})
}
async function updateRelationships()
{
await fetch('http://127.0.0.1/WebProjects/LARPLookup/Actions/Game/Relationships.cfm')
.then(response => response.text())
.then((response) => {document.getElementById("nav-relationships").innerHTML = response;})
}
async function updateSkills()
{
await fetch('http://127.0.0.1/WebProjects/LARPLookup/Actions/Game/Skills.cfm')
.then(response => response.text())
.then((response) => {document.getElementById("nav-skills").innerHTML = response;})
}
async function updateGoals()
{
await fetch('http://127.0.0.1/WebProjects/LARPLookup/Actions/Game/Goals.cfm')
.then(response => response.text())
.then((response) => {document.getElementById("nav-goals").innerHTML = response;})
}
async function updateBackground()
{
await fetch('http://127.0.0.1/WebProjects/LARPLookup/Actions/Game/Background.cfm')
.then(response => response.text())
.then((response) => {document.getElementById("nav-background").innerHTML = response;})
}
async function updateCharacterPages()
{
updateItems();
updateKnowledge();
updateRelationships();
updateSkills();
updateGoals();
updateBackground();
}
这些页面中的每一个都提取页面的完整 HTML 并将其放入具有该 ID 的 div 中。
<cfif Relationships.recordcount GT 0>
<div class="tab-pane fade" id="nav-relationships" role="tabpanel" aria-labelledby="nav-relationships-tab">
<cfinclude template="Relationships.cfm">
</div>
</cfif>
<cfif Skills.recordcount GT 0>
<div class="tab-pane fade" id="nav-skills" role="tabpanel" aria-labelledby="nav-skills-tab">
<cfinclude template="Skills.cfm">
</div>
</cfif>
<cfif Items.recordcount GT 0>
<div class="tab-pane fade" id="nav-items" role="tabpanel" aria-labelledby="nav-items-tab">
<cfinclude template="Items.cfm">
</div>
</cfif>
问题是,如果我运行它(使用 8 秒的 setInterval),它会产生这样的东西。
<tr>
<td>Player B</td>
<td>It's a good town.</td> (This is a knowledge and it should be a relationship)
</tr>
或
<tr>
<td></td>
<td>You really like this guy</td>
</tr>
有时,它做对了,但其他时候,就不是那么多了。
我应该从哪里着手解决这个问题?
我试着放慢循环速度,但在 8 秒后处理它仍然搞砸了,当我为 40-60 人运行它时,它肯定会失败。