首先,是的,我在发布此问题之前搜索了网站并遵循了一些建议,但仍然得出了相同的结果。我还会告诉你,这段代码很旧,并且在2012年在facebook上工作。我不是开发/编码器。我知道一些PHP。从我在一些帖子上看到的内容,他们通过将js向下移动到close标签附近来实现它。现在这就是我的问题所在。此代码不使用任何头部或身体标签。所以,如果我能弄明白这一点,它可能会帮助我解决其他java问题。以下是我在Chrome开发工具中提供错误的代码。
function recheck(what){
var ajax = new Ajax();
ajax.responseType = Ajax.JSON;
ajax.ondone = function(data) {
if(what=="energy"){
if(data.timeLeft>60){
numEnergySeconds = data.timeLeft
currEnergy = data.value;
did('energy').setTextValue(currEnergy);
if (currEnergy>=maxEnergy){
did('energyTime').setTextValue("");
}
energyCalled=false;//reset this
} else {
setTimeOut(recheck(what),data.timeLeft*1000);
}
} else if(what=="stamina"){
if(data.timeLeft>60){
numStaminaSeconds = data.timeLeft;
currStamina = data.value;
did('stamina').setTextValue(currStamina);
if (currStamina>=maxStamina){
did('staminaTime').setTextValue("");
}
staminaCalled=false;//reset this
} else {
setTimeOut(recheck(what),data.timeLeft*1000);
}
} else if(what=="health"){
if(data.timeLeft>60){
numHealthSeconds = data.timeLeft;
currHealth = data.value;
did('health').setTextValue(currHealth);
if (currHealth>=maxHealth){
did('healthTime').setTextValue("");
}
healthCalled=false;//reset this
} else {
setTimeOut(recheck(what),data.timeLeft*1000);
}
}
}
ajax.onerror = function() {
recheck(what)
}
ajax.post("<?echo $src?>resources/recheck.php", {"what": what});
}
function updateLevels() {
if (currStamina<maxStamina) {
numStaminaSeconds--;
if (numStaminaSeconds<0 && !staminaCalled) {
staminaCalled=true;
did('staminaTime').setTextValue("...")
recheck('stamina');
} else if(!staminaCalled && currStamina<maxStamina){
did('staminaTime').setTextValue(getLevelText(numStaminaSeconds));
}
} else {
did('staminaTime').setTextValue("")
Uncaught TypeError: Cannot call method 'setTextValue' of null
}
if (currEnergy<maxEnergy) {
numEnergySeconds--;
if (numEnergySeconds<0 && !energyCalled) {
energyCalled=true;
did('energyTime').setTextValue("...")
recheck('energy');
} else if (!energyCalled && currEnergy<maxEnergy) {
did('energyTime').setTextValue(getLevelText(numEnergySeconds));
}
} else {
did('energyTime').setTextValue("");
}
if (currHealth<maxHealth) {
numHealthSeconds--;
if (numHealthSeconds<0 && !healthCalled) {
healthCalled=true;
did('healthTime').setTextValue("...")
recheck('health');
} else if (!healthCalled && currHealth<maxHealth) {
did('healthTime').setTextValue(getLevelText(numHealthSeconds));
}
} else {
did('healthTime').setTextValue("");
}
}
function getLevelText( val ) {
var numMinutes = Math.floor(val / 60);
var numSeconds = val % 60;
if (numSeconds<10) numSeconds = "0"+numSeconds;
return ("("+numMinutes+":"+numSeconds+")");
}
我放入了面板中出现错误的位置。我知道代码可能不是很漂亮或最新,但我愿意接受如何解决这个问题的建议,而不需要雇用编码器来重写文件中的js。