Andy, this is also good to know.  I guess I'll figure this out eventually,
but what doesn't yet make sense is how to handle complex objects (queries,
structs) being returned from the CFC.  Do you just handle the formatting in
your CFC so you can pass back (or simply output, I guess) a string and use
$("#element").html() to replace the content, or do you handle formatting on
the client side?  (By "you" I mean Andy specifically but the rest of you
generally as well.)

 

I'm learning a lot.

 

Paul

 

 

  _____  

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Andy Matthews
Sent: Tuesday, February 06, 2007 2:07 PM
To: 'jQuery Discussion.'
Subject: Re: [jQuery] AjaxCFC (paging Rey Bango...)

 

Just so you know, you CAN use jQuery to hit the CFC directly. Here's a
sample of code I'm using:

 

js code:

function addRecipe(id) {
 $.get("includes/q.cfc?method=addRecipe&id=" + id,function(result){
  eval( 'var ' + result );
  $('#shoppingList').html(r.content);
 });
};

 

CFC:

<cffunction name="addRecipe" access="remote" returntype="void" hint="Adds a
recipe to your shopping list">
 <!--- set parameters for arguments --->
 <cfargument name="id" required="Yes" type="numeric">
 <cfset myStruct = structNew()>
 <cfif NOT ListFind(SESSION.grocerylist,id)>
  <cfset SESSION.grocerylist = ListAppend(SESSION.grocerylist,id)>
 </cfif>
 <cfset myStruct["content"] =
Replace(getShoppingList(),"#chr(13)#","","ALL")>
 <cfwddx action="CFML2JS" input="#myStruct#" toplevelvariable="r">
</cffunction>

 

 

 

 

 
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to