You cant break the string into individual arguments. It will be one
argument that contains a string with comma separated values, which can be
easily handled with CFs list functions. I'm not sure what you want to do
with them in your CFC, but you can loop through the values like so:

<cfloop list="#arguments.specialIDList#" index="local.loopIndex">
  ... here you have access to each value individually to work with....
</cfloop>


On Thu, Jan 16, 2014 at 2:11 PM, Rick Faircloth <[email protected]>wrote:

>
> Hold the horses!
>
> I changed the join from:
>
> specialIDList.join();
>
> to:
>
> var specialIDList = specialIDList.join();
>
> and it worked!
>
> I think the var, specialIDList, was not available to the ajax function
> since it was being recreated
> in the .each loop.
>
> So, now do I have to loop over the multiple variables in specialIDList on
> the server side with CF
> in order to break the string into individual arguments?
>
>
>
>
> On Thu, Jan 16, 2014 at 2:07 PM, Rick Faircloth <[email protected]
> >wrote:
>
> > Hi, Steve...
> >
> > I just gave that a try, but still get an error in Firebug:
> > "500 Element SPECIALIDLIST is undefined in ARGUMENTS"
> >
> > Also, in the console, I still get what appears to be the same when I use
> > console.log(specialIDLlist):
> > [ "27", "28", "26" ].
> >
> > Perhaps something is missing on the cfc method side? Here's that code:
> >
> > <cffunction     name               =     "mProcessEmailNewsletterForm"
> >   displayName    =  "mProcessEmailNewsletterForm"
> >   hint                  =  "Processes Email Newsletter Form"
> >   output              =  "true"
> >   access             =  "remote"
> >   returnType        = "struct" >
> >
> >   <cfargument name = "emailNewsletterGreeting" type = "string" required =
> > "no" />
> >   <cfargument name = "specialIDList"                  type = "string"
> required
> > = "no" />
> >
> >   <cfset emailNewsletterStruct = structNew() />
> >
> >   <cfset emailNewsletterStruct.EMAILNEWSLETTERGREETING =
> '#arguments.emailNewsletterGreeting#'
> > />
> >   <cfset emailNewsletterStruct.SPECIALIDLIST =
> '#arguments.specialIDList#'
> > />
> >
> >   <cfreturn emailNewsletterStruct />
> >
> > </cffunction>
> >
> >
> > ???
> >
> >
> >
> >
> > On Thu, Jan 16, 2014 at 12:50 PM, Steve Milburn <[email protected]
> >wrote:
> >
> >>
> >> Inside your .each loop you want to push specialID to your array like so:
> >> specialIDList.push (specialID). Afterwards when you are preparing your
> >> values object to be sent to the server you do specialIDList.join to put
> >> them into a string.
> >> On Jan 16, 2014 12:32 PM, "Rick Faircloth" <[email protected]>
> >> wrote:
> >>
> >> >
> >> > Here's the client-side code:
> >> >
> >> > $(document).ready(function() {
> >> >
> >> >   $('#newsletter_preview_button').click(function() {
> >> >
> >> >   var emailNewsletterGreeting = $('#email_newsletter_greeting').val();
> >> >
> >> >   var specialIDList = [];
> >> >
> >> >   $('.special_title_checkbox:checked').each(function() {
> >> >
> >> >   var specialID = $(this).attr('id').split('_').pop();
> >> >   specialIDList = specialID.join(', ');
> >> >
> >> >   });
> >> >
> >> >   console.log(specialIDList);
> >> >
> >> >   values     =  {     emailNewsletterGreeting:
> >> emailNewsletterGreeting,
> >> >   specialIDList:                      specialIDList
> >> }
> >> >
> >> >
> >> >   $.ajax            ({  cache:                                false,
> >> >   type:                                  'post',
> >> >
> >> >
> >> >
> >>
> 'email-newsletter.cfc?method=mProcessEmailNewsletterForm&returnFormat=json',
> >> >   data:                                  values,
> >> >   success:                            function(response) {
> >> >
> >> >   alert('Success!');
> >> >
> >> >   }
> >> >           });
> >> >
> >> >   });
> >> >
> >> > });
> >> >
> >> > On Thu, Jan 16, 2014 at 11:02 AM, Raymond Camden <
> >> [email protected]
> >> > >wrote:
> >> >
> >> > >
> >> > > On Thu, Jan 16, 2014 at 9:54 AM, Rick Faircloth <
> >> > [email protected]
> >> > > >wrote:
> >> > >
> >> > > >
> >> > > > Hmmm...
> >> > > >
> >> > > > I tried using the specialIDList.push(specialID) approach, and I
> get
> >> the
> >> > > > correct
> >> > > > output in console.log,  [ "27", "28", "26" ], but I also get the
> >> error
> >> > in
> >> > > > Firebug,
> >> > > > "500 Element SPECIALIDLIST is undefined in ARGUMENTS.
> >> > > >
> >> > >
> >> > >
> >> > >
> >> > > >
> >> > > > I also tried using specialIDList = specialID.join(', ') and I
> still
> >> get
> >> > > the
> >> > > > same
> >> > > > output in console.log, [ "27", "28", "26" ], but I also get the
> same
> >> > > error
> >> > > > in Firebug,
> >> > > > "500 Element SPECIALIDLIST is undefined in ARGUMENTS.
> >> > > >
> >> > >
> >> > > Ok, so you passed specialidlist, right? Can you show us your latest
> >> code?
> >> > >
> >> > >
> >> > > >
> >> > > > So, the cfc method doesn't understand speciaIDList when it's sent
> in
> >> > the
> >> > > > form
> >> > > > above, even when I specify the argument as "array" type.
> >> > > >
> >> > >
> >> > > Remember, we are sending the data over the wire as a string. So your
> >> > > argument should be string.
> >> > >
> >> > > But for now, let's see your client side code again please.
> >> > >
> >> > >
> >> > >
> >> >
> >> >
> >>
> >>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:357450
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to