Hello everyone,
This question is often asked, and I know there are lots and lots of answers that I could be using, but I just want a clear good answer.
I am making a website (for playing a game called Go).
It has a page for each game of course.
I'm making the website in PHP and MySQL, I know that for 'real-time' games another solution would probably be better, but I'm learning to master php and MySQL.
The game is shown via the <canvas> tag (using php and mysql to write the javascript, with in its turn writes the <canvas>).
Now it can happen that the game develops in one browser, but the old game board is still shown in the other.
I want to solve this issue using AJAX page refreshing.
I think it's possible to refresh the game every like 10/20/30 seconds, without the page reloading, so the page also doesn't go back to the top every refresh, but stays at it's scroll position.
The clearest answer to my problem i found here:
http://aleembawany.com/2005/09/01/ajax-instant-tutorial/
...now all I really have to do is add an automatic timer, so the div containing the game board automatically refreshes.
...Could someone help me, pretty much step by step? ( I may know a bit about html/php/mysql/css/design and stuff, but I REALLY REALLY suck with javascript. My javascript is usually just copy/paste work... )
Cheers!
Kelley van Evert
4 5272
Well, you see:
I'm using a javascript function in the <head>, to write to the <canvas> tag.
The tutorial I link to, see above, uses getElementById, but <script> doens't support an id (I think?).
...so how do I reload the data into the head?
This is a part of the <head>, and <body>: -
<?php
-
// displayPageType_game -> 475
-
// this is where the javascript is loaded that writes to the <canvas> tag...
-
$canvasId = "gameBoard";
-
$canvasSize = 475;
-
$dotSize = 3;
-
$lineSize = 1;
-
$lineColor = "#bbbbbb";
-
$radiusPixAdjust = -1;
-
$extraBorder = 1;
-
displayBoard($gameid, $canvasSize, $canvasId, $dotSize, $lineSize, $lineColor, $radiusPixAdjust, $extraBorder);
-
?>
-
</head>
-
<body onLoad="canvasDraw();">
-
... and here is the canvas: -
<canvas id="<?php echo $canvasId;?>" width="<?php echo $canvasSize;?>" height="<?php echo $canvasSize;?>">
-
You are using a browser that doesn't support the <canvas> tag.
-
</canvas>
-
acoder 16,027
Recognized Expert Moderator MVP
A script tag can have an ID. There's no JavaScript in the code that you posted above. Post that too.
Note: If you set the src of a script tag, it will execute the code within the source file.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Matthew Ferri |
last post by:
I'm using Windows 2000 Pro SP4 and Office 2000 Pro Sp3.
I have some dynamic database pages that I do not want a user to see from
their local cache of pervious visits to this page.
When these...
|
by: Gerard M Foley |
last post by:
Can one write a webpage which is not displayed but which simply redirects
the user to another page without any action by the user?
Sorry if this is simple, but I am sometimes simple myself.
...
|
by: Nico VanHaaster |
last post by:
Hello all,
I have run across an issue with IE 6.0+. I have a page that makes an
XMLHttpRequest to the webserver to update a report on the page. The
first time you hit the refresh report button...
|
by: angiemc |
last post by:
Hi,
I have a question about AJAX and ASP.Net controls.
I'm working on a system that requires pages to be generated dynamically based on XML to provide the layout (eg text boxes, dropdowns, save...
|
by: Piotr Nowak |
last post by:
Hi,
Say i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig it.
I do not want to refresh my page i.e....
| |
by: paulie |
last post by:
Hi,
I have been experiencing an issue when trying to use AJAX to reload a DIV area
using a timer of 2000ms, which contains a html page with another DIV and javascript.
Scenario
-------------...
|
by: Mark B |
last post by:
This is my first try at using AJAX. I want the calendars to be enabled if
the user checks CheckBox1. It works OK for a normal all page refresh but
once I introduced the AJAX code it stopped...
|
by: canabatz |
last post by:
Hello , i got this code that works great , now i want to have it refresh every 4 seconds , where can i put the timer to do that?
i realy need help!!
thanx!!
<script type="text/javascript">...
|
by: eihabisaac |
last post by:
hi all
i want to refresh a div using ajax,
i wrote this code:
index.php
<script src="ajax/moniter/moniter.js" type="text/javascript"></script>
<body onload="moniter();">
<div id="moniter">
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |