Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Server->Client communication with php/mysql/jquery

Posted on 2010-11-08
4
Medium Priority
?
502 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

688 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