Solved

Server->Client communication with php/mysql/jquery

Posted on 2010-11-08
4
475 Views
Last Modified: 2012-05-10
Here is what I am trying to make happen:

Anytime there is an update to a certain variable in my database, I would like that new variable to be sent to any client logged into my site and automatically update asynchronously on their page.  Is there a way to asynchronously have the client's browser be constantly checking that variable/variables in the database to see if they have changed with PHP/JQuery?  What is the best way to handle something like this?
0
Comment
Question by:ncotherman2
  • 3
4 Comments
 
LVL 6

Expert Comment

by:ramelong
ID: 34086947
To develop a, efficient method, firstly there some things to know:
- How these variables are updated?
- How you currently know who is logged and who don't?
- These variables to e updated at client side: in which language are working? In javascript?

But on the other hand you may check these variables in several ways:
- Every time the page is loaded (or reloaded).
- With a timer in javascript (unrecomended on IE because of the "tick" sound).
- With a timer in javascript that check a php program into a layer. This program must have to update the variables.
0
 

Author Comment

by:ncotherman2
ID: 34088160
The database variables are updated by other users on the site.

Yes I currently know who is logged on.

Right now I am retrieving the variables with php.


So in order to be constantly checking these variables I would need to have a constantly running Javascript loop?  Wouldn't that significantly affect performance?
0
 
LVL 6

Accepted Solution

by:
ramelong earned 500 total points
ID: 34088297
Well, depends on the delay between readings... and the amount of logged users.

If these variables aren't required until the reload, the best you can do is read them at the begining of the PHP program. In any other case, you need a timer triggered reader...

In order to update javascript variables, needed to modify vehaviours on the client, a practical way is to linking the reading action to a button action, for instance, you may read the variables  (with AJAX) every time the user clicks on the icons or buttons (for this you may use the onClick event in those elements).

Remember that PHP variables are used at server side, and javascript variables are used at client side.
0
 
LVL 6

Expert Comment

by:ramelong
ID: 34093383
Good luck with your project!
RA
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now