Calling Functions from Functions.
I am playing around with Ajax in a chat script I am making, and have encountered some loading problems.
I have a function Init() which initiates on load.
This runs getMessages(); and sets an interval of 2 seconds, to continue running it. This gets the messages from the database.
I want to also get details of who is online at a given time from a separate database. I have done the exact same again. I run getOnline(), and then set it to run every 2 seconds using setInterval();.
When I introduce the getOnline();, getMessages(); no longer works... no messages are displayed on the page. As soon as I remove it, it is fine. Likewise if I remove getMessages(); getOnline(); works fine.
Why is this?
I attempted another idea. I had:
then rather than do the same for getOnline();, I called the function getOnline(); from getMessages();
I.E getMessages is run every 2 seconds, and when called it also runs getOnline();
Once again getOnline() works.. I can see who is online, but I cannot see any messages.
Have I missed something here, or am I doing something wrong.
This is not a code problem: the code works fine, simply they do not work together. Have I missed some intrinsic rule about how things can be called?