Sunday, August 29, 2010

Re: passing variables to controller function from JS

I make use of the automatic url parsing and pass my URLs in the form
controller/action/var1:value1/var2:value2/etc:etc

This provides two benefits, one you setup your actions like this:

function action_name(var1, var2) { if your always going to submit in
the same order

or you can make use of the named variables so that order no longer
matters.

you then setup your action to not use any parameters and instead check
the named variables existence and value like this:

function action_name() {
if (!empty( $this->params['named'][var1'] ) {
$var1 = $this->params['named'][var1'];
}
else {
die('var1 is empty');
}

On Aug 29, 8:14 am, Tomfox Wiranata <tomfox.wiran...@gmail.com> wrote:
> hi,
>
> i have this function called in my view. it is JS.
>
> ajaxUpload(form,'processFlyer','flyer_css','<img src=\'../img/icons/
> loader.gif\' width=\'16\' height=\'16\' border=\'0\' />','Fehler beim
> Upload');
>
> the processFlyer is a function in my controller. how can i pass
> variables with this call?
>
> i know it works with jquery like this
> $('#flyer_preview').('countattachments', {attachmentcount: count});
>
> but not with pure JS...
>
> big thx  :)

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: