Can you execute a function on trigger from a php file / ajax?

Hi,

I have a website which has a mysql db which records how many visitors i have.
I want a message box to pop up everytime a visitor logs on.

Whenever someone logs on, a php file constantly is run (via javascript) checks to see if the visitor counter has increased.
if it does it plays a “ping” sound. this works fine, but I think as the php file is seperate from my index.php
the message never appears.

is there a way to check in javascript that when a responsetext (ajax) changes from the current value being polled that it executes a function? (ie, the notify box)

many thanks… twisting my melon… kev

You can store the responseText in a global variable. When the next ajax request is sent to check if any more visitors have logged in, compare its responsetext value with the global variable value and if the visitor count has increased display an appropriate message. This can all be done in your onreadystatechange handler.