PDA

View Full Version : Can get this simple cfc to work.



jrdeveloper
August 29th, 2012, 01:18 PM
Hi, I am trying to run this code which includes a simple call to a cfc. The idea here is to type something into the input box, press the ok button, reply "ok" to the confirm box and have the cfc return what was typed. Very simple, just doing this to later update an application to use components. When the cfc returns the text, I get this error on my left bottom portion of my browser and the reply from the cfc is not displayed. Any suggestions, by the way, this work just fine on another CF site.

Message: Exception thrown and not caught
Line: 804
Char: 1
Code: 0
URI: http://www.istarlightcommunications.com/CFIDE/scripts/ajax/package/cfajax.js

cfm page:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<cfajaxproxy cfc="mytestcfc" jsclassname="mytestcfc" />
<title>Test CFC</title>

<script language="JavaScript1.2" type="text/javascript">
function showUpdtDetail(r)
{

alert(r);
}

function Verify()
{

var chk;
chk=confirm("Are you sure you want to Test CFC Call");
if(chk == true)
{
var instance = new mytestcfc();
instance.setCallbackHandler(showUpdtDetail);
instance.myFunction(document.getElementById("testinput").value);
}
else return false;
}
</script>
</head>

<body>
<cfform name="myfrm">
<cfinput name="testinput" id="testinput"><br />
<cfinput type="button" Value="Test CFC Call" name="delbtn" id="delbtn" onclick="javascript:Verify()" >
</cfform>

</body>
</html>

cfc page:

<cfcomponent>
<cffunction name="myFunction" access="remote" output="false" returntype="string">
<cfargument name="myArgument" type="string" required="yes">
<cfreturn myArgument>
</cffunction>
</cfcomponent>

jrdeveloper
August 30th, 2012, 10:52 PM
Thanks to David D. on the Hostek Support Team for helping me figure this out. Seems I had a couple of things in my directory that were causing my components not to compile, notably an "Onrequestend.cfm" with a <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> declaration tag. I removed that tag from my files as I had it in multiple places and all seems to be working great. David also turned me on to this little trick that really helped. To see if your cfc will compile, add "?wsdl" to your cfc link. It will return xml code if it compiles or an error message to help you debug.

http://www.yoursite.com/ajax/yourcfc.cfc?wsdl