Wat doe ik verkeerd!?
myScript.js
var timeout;
$(document).ready( function(){
$(' #auto').load('load.php');
refresh();
startReload();
});
function refresh()
{
setTimeout( function() {
$(' #auto').load('load.php');
refresh();
}, 5000);
}
function stopReload() {
clearTimeout(timeout);
}
function startReload() {
timeout = setTimeout(function() { refresh(); }, 5000);
}
test.php
<html>
<head>
<script src="http://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="myScript.js"></script>
</head>
<body>
<div>
<div id="auto"></div>
<br></br>
<button onclick="stopReload();">Stop</button>
<button onclick="startReload();">Start</button>
</div>
</body>
</html>
Als dit script werkende is plaats ik het graag in de sectie PHP Scripts(Jquery refresh div sectie met start/stop buttons).