Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Coldfusion Ajax timer probelms

Posted on 2009-05-20
6
Medium Priority
?
695 Views
Last Modified: 2013-12-24
So i needed to be able to check an inbox, and found this post:
http://www.experts-exchange.com/Software/Server_Software/Web_Servers/ColdFusion/Q_24346330.html?sfQueryTermInfo=1+10+8+ajax+coldfus+timer

My problem is that in firefox nothing happens & IE throws an error - ive since found out, im getting "Error thrown and not caught" at line 798 within cfajax.js

Current result can be seen at http://www.brandirectorv2.com/test.cfm
<!--- test.cfm --->
<cfajaxproxy cfc="includes.inbox" jsclassname="inboxProxy">
<head>
<script type="text/javascript">
var p = new inboxProxy();
var checkInbox = function(userid){
 p.setCallbackHandler(updateInbox);
 p.setErrorHandler(pErr);
 p.checkUserInbox(userid);
};
var updateInbox = function(result){
 document.getElementById("messagecount").innerHTML = " ("+result+")";
};
var pErr = function(code, message){
 alert("Error! Could not check your inbox...\nError Code: "+code+"\nError Message: "+message);
};
var initInboxCheck = function(userid){
 checkInbox(userid);
 setInterval(checkInbox(userid), 5000);
};
</script>
</head>
<cfset user_id="1">
<body onload="initInboxCheck(<cfoutput>#user_id#</cfoutput>);">
<div id="header"><a href="viewinbox.cfm">INBOX<span id="messagecount"></span></a></div>
</body>
</html>
 
<!--- includes/inbox.cfc --->
<component displayname="inbox" output="no">
<cffunction name="checkUserInbox" access="remote" returntype="numeric" output="no">
 <cfargument name="userID" type="numeric" required="yes">
 <cfset var queryInbox = "">
 <cfquery name="queryInbox" datasource="#request.dsn#" username="#request.uid#" password="#request.pwd#">
 SELECT * FROM tbl_messages WHERE msg_to = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.userID#">
 </cfquery>
 <cfreturn queryInbox.recordcount />
</cffunction>
</component>

Open in new window

0
Comment
Question by:j-tanner
[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
  • 3
6 Comments
 
LVL 27

Accepted Solution

by:
azadisaryev earned 1000 total points
ID: 24437833
the correct tag is <CFcomponent> - not <component>...

Azadi
0
 
LVL 27

Assisted Solution

by:azadisaryev
azadisaryev earned 1000 total points
ID: 24437841
yes, i see i had that typo in my code in the other question... sorry! my bad!

Azadi
0
 
LVL 27

Assisted Solution

by:azadisaryev
azadisaryev earned 1000 total points
ID: 24437852
i have posted an update in the other question, so hopefully no one else will fall into this... sorry you had to be the one!

Azadi
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:j-tanner
ID: 24438486
Hi,

Thankyou for the reply, that has stopped the cfajax error :), however the script is still failing...
Firebug shows:

useless setInterval call (missing quotes around argument?)
                                   setInterval(checkInbox(userid), 5000);

I researched setInterval & many say that whilst you can call a function, you cant pass a variable? if i put speech marks around it, it still stops & firebug says "userid is not defined"

Any thoughts?
0
 

Author Comment

by:j-tanner
ID: 24438568
Actually, i solved it :D... you may want to update code in he other post as well...

i replaced:

setInterval(checkInbox(userid), 5000);

with:

setInterval(function(){checkInbox(userid)}, 5000);
0
 

Author Closing Comment

by:j-tanner
ID: 31583601
Thankyou for your help
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

636 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