views:

41

answers:

3
+1  A: 

Without seeing an actual error, my guess is that your problem is with using an unscoped variable name the same as a function. Instead of and putting that just after the argument tag. Then later in your code use the countNew variable.

One other thing...please, plesae, plesae use cfqueryparam in your queries when you are passing in variables. This protects you from sql injection attacks (and improves performance). For instance:

<CFQUERY NAME="NoCountCK" DATASOURCE="MyDSN">
SELECT *
FROM Ideas
WHERE IdeaID = <cfqueryparam value="#arguments.VoteNo#">
</CFQUERY>
Sam Farmer
The error was something I made the cfc do just to see if it was even being called up. Not to worry Sam I always use cfqueryparam on all my queries. Just didn’t put them in my example as I wanted to keep the code simple so someone could see what I did wrong. I put the "NewCount" variable in and that solved updating the count in the database but that is as far as it works. The query insert is still not working. I am going to try some different things and see if I might get something right.
Kelly Kc Clements
A: 

First, I think you're never calling the "NewCount" function in the MyCFC component. As the cfajaxproxy docs demonstrate (http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_a-b_3.html), you call cfajaxproxy, initialize a JavaScript object, and call a method on that object. So in your case it would be "cfc.NewCount(true)" (note this is case sensitive) after the "cfc.setCallbackHandler(getDataResult);".

Next, to check yourself, use Firefox with Firebug. This will allow you to easily JavaScript errors and AJAX requests. Load your page with Firebug running. Check the Firebug console for JavaScript errors. If it's complaining it can't find the library cfajax.js then you probably need to setup a web server mapping to the CFIDE directory - where ColdFusion keeps its various JavaScript files that it ships with.

Finally, click the "Vote" button. Check the AJAX requests in Firebug to see something's fired off. See what the response code is. Not 200? Open the request in the Firebug console to see the response HTML. You can right click the response to open in a new browser tab.

orangepips
Thanks orangepips I did put the "NewCount" variable in after the "cfc.setCallbackHandler(getDataResult);" and that did solved updating the count in the database but that is as far as it works. The query insert is still not working. I am now getting an “Error Executing Database Query” error. I am going play around with it, I might get lucky. If you see something please let me know.
Kelly Kc Clements
I updated the code above and add what is going on with it now.
Kelly Kc Clements
Looks to me like the MemberVote cfquery call is missing single quotes around the "N" as the last value to be inserted. Also, are you getting anything in exception.log?
orangepips
Yes they are but that wasnt the problem. when I chaned the YesNo feild name all was good. I also changed document.write() to var content = document.getElementById('NoCount').innerHTML=result; which stopped it from overwritting my dom
Kelly Kc Clements
Can you go look at `http://stackoverflow.com/questions/3910945/how-to-pass-an-onclick-link-value-to-javascript-and-cfc-though-cfajaxproxy`, see if you know what to do?
Kelly Kc Clements
A: 

Ok I fixed the document.write overwriting the entire DOM by replacing document.write(result) with this var content = document.getElementById('NewCount').innerHTML=result;. This seems to keep the change within the <SPAN ID=" NewCount' > </SPAN> and not overwriting my page.

I fix why my cfc wouldn’t add the members vote in the CFQUERY “MemberVote" to the database. I was getting an “Error invoking CFC: Error Executing Database Query”. I had to re-label a field in the table. For some reason executing the table though the cfc didn’t work when it works outside the cfc.

Kelly Kc Clements