Computing.Net > Forums > Web Development > JS/PHP: Update w/Call to 2nd Page

JS/PHP: Update w/Call to 2nd Page

Reply to Message Icon

Original Message
Name: Michael J (by mjdamato)
Date: June 30, 2005 at 07:13:41 Pacific
Subject: JS/PHP: Update w/Call to 2nd Page
OS: XP Pro
CPU/Ram: 2.4GHz / 1GB
Comment:

Hey guys, here is the situation. I have a custom "block" for PHPNuke which displays the details of a TeamSpeak server, such as the users who are connected to the server. I want to create a javascript function that will allow the content of that block to be refreshed without having to reload the whole page.

I can handle the actual updating of the content using a div and the innerHTML handler, but my problem is getting the updated content. My plan is to have a JavaScript function with a timer (using setTimeout) to call a php page every x seconds - that php page will make the necessary calls to the TS server and get the new content.

So, what is the best method of getting that information back to the function on the main page to be acted upon? I have some ideas (such as passing a variable back tot he main page), but I would need to add another timer to wait before acting upon it to allow the 2nd page to complete. I was hoping for something a little more elegant. Or, is there another method that I am not thinking of?

Michael J


Report Offensive Message For Removal

Response Number 1
Name: Coliver
Date: July 4, 2005 at 23:50:03 Pacific
Subject: JS/PHP: Update w/Call to 2nd Page
Reply: (edit)

I assume that you are using a PHP Nuke Module. Remember to specify this to make the helper's work easier.

I advise against using JavaScript to refresh pages.

A) It consumes bandwidth. Especially with nuke, the module appears on every page. Several megs of bandwidth per person per minute is typical. Unless you have a lot, otherwise I wouldn't do this.

B) Exploits. People can see the path to your server files if you do this. PHP files are naturally hidden to the source. But if you add JavaScript, your files will be exposed, along with important paths and critical information.

As for if you want to do it, I would use your method. It's probably the most simplest way that I can think of off the top of my head.


Report Offensive Follow Up For Removal

Response Number 2
Name: Michael J (by mjdamato)
Date: July 5, 2005 at 13:24:24 Pacific
Subject: JS/PHP: Update w/Call to 2nd Page
Reply: (edit)

Coliver,

Thanks for the reply. But, I'm not sure I follow (or perhaps I didn't make myself clear).

yes this is for PHPNuke. However, I want to have a JavaScript function call a PHP page that will do the work of making the request to the TeamSpeak server. So, all of the paths and other information would be in the PHP page and hidden from the users. Plus the PHPNuke page would not need to be refreshed - conserving bandwidth.

What I'm trying to figure out is how to get the information that the PHP page will generate back to the JavaScript function on the main page. Any ideas?

Michael J


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: JS/PHP: Update w/Call to 2nd Page

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software