Currently, I have a web app index page that performs two main tasks. Firstly, it geocodes the user's location and stores it in a JavaScript variable called "variableToSend." Secondly, it sends this data to mySQL using a PHP script after a delay of 10 seconds to allow time for the client side to capture the location.
While everything is functioning well, there is one issue - the setTimeout function I am utilizing continues to run every 10 seconds when I only need it to execute once on the page.
Below is the code snippet:
<script language="JavaScript">
setTimeout(function(){
var variableToSend = document.getElementById("latLng");
document.forms[0].submit();
$.post('html/index.php', {$latLong: "variableToSend"});
//window.clearInterval(interval);
}, 10000);
</script>
I would greatly appreciate any assistance with resolving this issue. Please let me know if you require further information.