The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Web Design
> JavaScript Development
|
Need help in update values without refreshing
Discuss Need help in update values without refreshing in the JavaScript Development forum on Dev Shed. Need help in update values without refreshing JavaScript Development forum discussing JavaScript and DHTML, AJAX, and issues such as coding cross-browser JavaScript.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

November 15th, 2006, 08:19 AM
|
|
Registered User
|
|
Join Date: Nov 2006
Posts: 4
Time spent in forums: 42 m 57 sec
Reputation Power: 0
|
|
Need help in update values without refreshing
Hi guys. I'm having a prob here and would like some help  . The basic idea is I am making a web based game, an interactive one. The game is able to create different rooms for 1 vs 1 battle.
For every room created, a php file named as the room name is created which keeps a temp record of the players status example ($HP = 200  and things like that. This php file updates in real time during gameplay. I include this php into the players page so it can display the status, but however I can't auto update it real time without refresh.
So is there anyway I can re-include the php file every x seconds so that the old values can are updated with new ones? Or anyway I can keep retrieving the new update values from the php file to work with? Thanks in advance  .
|

November 15th, 2006, 06:52 PM
|
 |
(retired)
|
|
Join Date: Dec 2003
Location: The Laboratory
|
|
|
You want "AJAX", where the J is for Javascript.
--Simon
|

November 16th, 2006, 02:33 AM
|
|
Registered User
|
|
Join Date: Nov 2006
Posts: 4
Time spent in forums: 42 m 57 sec
Reputation Power: 0
|
|
I've read up on AJAX and some AJAX examples on the net. But most examples on the net only show results in text without refresh. So if AJAX is the best solution to it, can anyone show me the way to update the values using AJAX every x seconds  ? Sorry but I really know nuts with AJAX or you can also say i am very noob in writing scripts, lolz  .
|

November 17th, 2006, 02:42 AM
|
|
Registered User
|
|
Join Date: Nov 2006
Posts: 4
Time spent in forums: 42 m 57 sec
Reputation Power: 0
|
|
Hey, I've found the solution to it. Thanks for the help anyway but i've another problem rising after this one that I've overlooked, damn. lolz  ! I call the following functions every x seconds using a js setTimout().
Quote:
function include_dom(script_filename) {
var html_doc = document.getElementsByTagName('head').item(0);
var js = document.createElement('script');
js.setAttribute('language', 'javascript');
js.setAttribute('type', 'text/javascript');
js.setAttribute('src', script_filename);
html_doc.appendChild(js);
return false;
} |
but after a few tries of retrieving the file from server, the browser don't bother to fetch and it keeps retrieving the old file inside my temp internet folder which has the old data.
Can anybody care to help me with this?
|

November 17th, 2006, 12:15 PM
|
 |
4:04 Time Not Found
|
|
Join Date: Jan 2004
Location: Northern Virginia
|
|
Try calling include_dom() with something like this, it should trick the browser into reloading a full version of your js every time.
Code:
var src = 'http://whatever.com/whatver.js?'+ Math.random() +'';
include_dom(src);
__________________
I am so smart, I am so smart, S.M.R.T ... I mean S.M.A.R.T.
Stop Using Pop-Ups
|

November 18th, 2006, 12:44 PM
|
|
Registered User
|
|
Join Date: Nov 2006
Posts: 4
Time spent in forums: 42 m 57 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by vbrtrmn Try calling include_dom() with something like this, it should trick the browser into reloading a full version of your js every time.
Code:
var src = '(URL address blocked: See forum rules)/whatver.js?'+ Math.random() +'';
include_dom(src);
|
Bingo  ! Indeed a simple line can counter the "stupid" browsers prob. Oh.... I got bad headaches for days cuz of this problem  . Very big thks vbrtrmn  ! No more panadols for me lolz. Cheers 
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|