Hey I am writing this Javascript function that runs every 1 minute using the setTimeout() function. Basically it is ment to run every 1 minute and post a user id and a unique key to a PHP script and then the PHP script updates the database. This is the code:
online.php
PHP Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title here</title>
<script type="text/javascript" src="jquery-1.2.1.pack.js"></script>
<script type="text/javascript" src="online.js"></script>
</head>
<body onLoad="UpdateUserOnline(8, 'c89017bf298df1048faac7abce9291ac' )">
</body>
</html>
online.js
The onlinecheck.php at the moment only writes to a file the user_id and the login_key but when I run the online.php file and it loads the UpdateUserOnline() function the browser just freezes and when I view the file that the data is getting written to the size of it is just flying up by the second and it has thousands of lines in it.PHP Code:function UpdateUserOnline(user_id, login_key){
$.post("onlinecheck.php", {id: user_id, key: login_key } );
t = setTimeout(UpdateUserOnline(user_id, login_key ), 60000);
}
Ive tried looking everywhere and I can't seem to find a solution. I still don't see how it is running the function over 100 times a second when I told it to run every 60 seconds which im fairly sure is 60000 miliseconds. Any help would do. Thanks.


Reply With Quote




Bookmarks