Trexgreen
asked on
ColdFusion and AJAX to read query
I have a query that check if a user in my forum has a private message or not, I would like to create an AJAX for this query that it will be checking for new private messages every 5 minutes or so, and update the inbox variable.
Right now this query executes everytime the user logs in, and it will update the header menu for the inbox.
example inbox menu:
INBOX ----> no message
INBOX (1) ---> 1 message
since this menu is in the header the query is executed everytime the page is reloaded or the user goes to another page, but I would like to add an AJAX code so that the menu is updaded without having to refresh the page.
I've been looking around and I cannot find any information on how to load a query every so often.
Thank you...
Right now this query executes everytime the user logs in, and it will update the header menu for the inbox.
example inbox menu:
INBOX ----> no message
INBOX (1) ---> 1 message
since this menu is in the header the query is executed everytime the page is reloaded or the user goes to another page, but I would like to add an AJAX code so that the menu is updaded without having to refresh the page.
I've been looking around and I cannot find any information on how to load a query every so often.
Thank you...
You can use <cfschedule>. Perhaps once the user logs in, create a new cfschedule that runs every 5 minutes. When the user logs out (and/or in your application.cfc's onSessionEnd() function) kill the cfschedule.
Sorry, my answer's not probably on the right tracks, as I guess you're looking for an Ajax solution. Look into Javascript timers instead.
ASKER
I can, but that would be the same as what I have now... everytime you change a page it would reload the query.
Why is it not a good idea to use AJAX for that?
Why is it not a good idea to use AJAX for that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
IMPORTANT UPDATE!
for anyone trying to use the solution: i have typo in my code!
the correct tag is, of course, <CFcomponent>, not <component>. make sure you correct this if you are using the code!
Azadi
for anyone trying to use the solution: i have typo in my code!
the correct tag is, of course, <CFcomponent>, not <component>. make sure you correct this if you are using the code!
Azadi
Something like this
<meta http-equiv="refresh" content="5; URL=http://www.someurl.com">
This will automatically refresh for every 5 seconds.