Solved

Server->Client communication with php/mysql/jquery

Posted on 2010-11-08
4
478 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
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 …

910 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

23 Experts available now in Live!

Get 1:1 Help Now