Я получаю «Uncaught ReferenceError: refreshAgonas не определен»ReferenceError Функция не расслоение плотной определено
Игроки ДИВ заполнена правильно. Нужно ли мне какое-то специальное определение с JS-функциями в JS-файле?
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
</head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-draw.js"></script>
<h2>Game</h2>
<div class="agonas">
<script>
setInterval(refreshAgonas, 5000);
var inRequesG = false;
</script>
</div>
<h2>Players</h2>
<div class="players">
<script>
setInterval(refreshPlayers, 5000);
var inRequest = false;
</script>
</div>
</html>
JQuery-draw.js
function refreshPlayers() {
if (inRequest) {
return false;
}
inRequest = true;
var load = $.get('playersdata.php');
$(".players").html('Refreshing');
load.error(function() {
console.log("Mlkia kaneis");
$(".players").html('failed to load');
// do something here if request failed
});
load.success(function (res) {
console.log("Success");
$(".players").html('<table border="1"><tr><th>ID</th><th>Name</th><th>Email</th><th>League</th><th>Sex</th><th>Birthday</th></tr>' + res + '</table>');
});
load.done(function() {
console.log("Completed");
inRequest = false;
});
}
function refreshAgonas() {
if (inRequestG) {
return false;
}
inRequestG = true;
var load = $.get('playersdata.php');
$(".agonas").html('Refreshing');
load.error(function() {
console.log("Mlkia kaneis");
$(".agonas").html('failed to load');
// do something here if request failed
});
load.success(function (res) {
console.log("Success");
$(".agonas").html('<table border="1"><tr><th>ID</th><th>Name</th><th>Email</th><th>League</th><th>Sex</th><th>Birthday</th></tr>' + res + '</table>');
});
load.done(function() {
console.log("Completed");
inRequestG = false;
});
}
Вы уверены, что путь к файлу JS правильно ? Попробуйте добавить «../» или другие элементы, которые помогут браузеру найти файл. – Askanison4
Обе функции находятся в файле jquery-draw.js. Почему бы refreshPlayers работать и обновлятьAgonas нет? Может, я должен объявить их каким-то другим способом? i dk – LefterisL
Ты уверен, что игроки загружаются? Вы видите console.log («успех»)? – Askanison4