Copy link to clipboard
Copied
I have trouble getting ajax to work on my application. I am using cfajaxproxy tag and I keep getting an error of "exception thrown but not caught". I am trying to get results back from the server of the query's recordcount. if its 0 then relocate the user, if its 1 then open a cfwindow..
heres my code:
<cfajaxproxy cfc="rem" jsclassname="rem"/>
<script>
function checkname(name){
var instance = new rem();
instance.setCallbackHandler(isfriend);
instance.setForm('nameform');
instance.checkname(name);
}
function isfriend(res){
if (res == 0)
ColdFusion.Window.show("addf");
else{
var locate = "test2.cfm?rel=";
window.navigate(locate + name);}
}
</script>
and here is my rem.cfc:
<!-- function to check if friend or not -->
<cffunction name="checkname" access="remote" returntype="numeric">
<cfargument name="ref" type="numeric">
<cfquery name="checkfriend" datasource="blog">
SELECT friendshipid FROM friends WHERE
UserID = #SESSION.IsLoggedIn.UserID#
AND FriendID = #ARGUMENTS.ref#
</cfquery>
<cfreturn int(checkfriend.recordcount)>
</cffunction>
thank you everyone
Copy link to clipboard
Copied
I would, for a start, define the functions as follows:
var checkname = function(name) {...}
var isfriend = function(res) {...}
and I would call setErrorHandler, for example, like this
instance.setErrorHandler(someErrorHandler)
Check out the live docs on cfajaxproxy
Copy link to clipboard
Copied
Hi,
Thank you for the reply, but it didn't work. In fact, I thought it had somthing to do with the built in ajax files on the server, yet, when I moved both my document and the cfc to a new location on the server, magic happened and it all worked out just perfect. So, I really don't know what happened exactly, but I'm sure that it has to do with the cfajax.js files on the server some how. I would like to thank you again for the reply
Ali