Solved

Coldfusion Ajax timer probelms

Posted on 2009-05-20
6
685 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
  • 3
  • 3
6 Comments
 
LVL 27

Accepted Solution

by:
azadisaryev earned 250 total points
Comment Utility
the correct tag is <CFcomponent> - not <component>...

Azadi
0
 
LVL 27

Assisted Solution

by:azadisaryev
azadisaryev earned 250 total points
Comment Utility
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 250 total points
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:j-tanner
Comment Utility
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
Comment Utility
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
Comment Utility
Thankyou for your help
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now