I have several users accessing my page at the same time, with each client polling (using setInverval) another php script that reads a value from a database and prints it.
setInterval( "printData();", 300 );
I'm relatively new to jQuery and javascript, and I'm a bit skeptical of the viability of constantly running this php script and constantly making database queries.
Can someone calm my nerves or provide an alternative to my current method?
You are updating it every 0.3 seconds - that's over 3 times a second. Way too much. Depending on how smooth it needs to be, update it at most every 5 seconds (5000
) instead.
Also, just to make it a little faster, just drop the quotes and parentheses:
setInterval(printData,5000);