JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 15th, 2006, 08:19 AM
toshie toshie is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2006
Posts: 4 toshie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 42 m 57 sec
Reputation Power: 0
Question 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 .

Reply With Quote
  #2  
Old November 15th, 2006, 06:52 PM
SimonGreenhill's Avatar
SimonGreenhill SimonGreenhill is offline
(retired)
Dev Shed God 11th Plane (10000 - 10499 posts)
 
Join Date: Dec 2003
Location: The Laboratory
Posts: 10,101 SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)SimonGreenhill User rank is General 6th Grade (Above 100000 Reputation Level)  Folding Points: 4925 Folding Title: Novice Folder
Time spent in forums: 3 Months 3 Weeks 6 h 8 m 34 sec
Reputation Power: 0
Facebook
You want "AJAX", where the J is for Javascript.


--Simon

Reply With Quote
  #3  
Old November 16th, 2006, 02:33 AM
toshie toshie is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2006
Posts: 4 toshie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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 .

Reply With Quote
  #4  
Old November 17th, 2006, 02:42 AM
toshie toshie is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2006
Posts: 4 toshie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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?

Reply With Quote
  #5  
Old November 17th, 2006, 12:15 PM
vbrtrmn's Avatar
vbrtrmn vbrtrmn is offline
4:04 Time Not Found
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2004
Location: Northern Virginia
Posts: 2,273 vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level)vbrtrmn User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 22 h 10 m
Reputation Power: 337
Send a message via ICQ to vbrtrmn Send a message via AIM to vbrtrmn Send a message via MSN to vbrtrmn Send a message via Yahoo to 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 = '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

Reply With Quote
  #6  
Old November 18th, 2006, 12:44 PM
toshie toshie is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2006
Posts: 4 toshie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Need help in update values without refreshing

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap