Shripad
2009-Mar-19 12:34 UTC
How to pass javascript variable value to a Session Variable in javascript
Hi all, Can any one tell me, how can I Pass a javascript variable value to a ROR session variale in javascript. Please help me out Thanks, Shripad --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Starr Horne
2009-Mar-19 13:49 UTC
Re: How to pass javascript variable value to a Session Variable in javascript
> Can any one tell me, how can I Pass a javascript variable value to a > ROR session variale in javascript.You can either: 1) Set a cookie in JS and have your rails app read the cookie. If you''re using not using DB-backed sessions, this may be sufficient. You may not need to use rails'' actual sessions mechanism. 2) Have your JS do an XHR request to a special controller action which will save your data to the session. -- Starr Horne Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Shripad
2009-Mar-20 05:21 UTC
Re: How to pass javascript variable value to a Session Variable in javascript
Hi Starr,
Thank u for ur nice reply.
I have done the first part what u have mentioned by using
"document.cookie".
I am new to XMLHttpRequest(XHR) will you please guide me a little more
on this with example.
I have following code written in javascript
var selObj = document.getElementById(''zone'');
var i;
var count = 0;
for (i=0; i<selObj.options.length; i++) {
if (selObj.options[i].selected) {
selectedArray[count] = selObj.options[i].value;
count++;
}
}
document.cookie="zone_ids=" + selectedArray.toString();
var r = document.cookie;
I want to pass this cookie value to my account controller method
say "add"
And after passing how can I access it in the controller?
I am googleing for the same but don''t find good materials.
Please help me out
Thanks and Regards,
Shripad
On Mar 19, 6:49 pm, Starr Horne
<st...-wG8FsLYNbnsysxA8WJXlww@public.gmane.org>
wrote:> > Can any one tell me, how can I Pass a javascript variable value to a
> > ROR session variale in javascript.
>
> You can either:
>
> 1) Set a cookie in JS and have your rails app read the cookie. If
you''re using not using DB-backed sessions, this may be sufficient. You
may not need to use rails'' actual sessions mechanism.
>
> 2) Have your JS do an XHR request to a special controller action which will
save your data to the session.
>
> --
> Starr Horne
> Check out my Helpdesk RailsKit:http://railskits.com/helpdesk/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
Shripad
2009-Mar-20 06:44 UTC
Re: How to pass javascript variable value to a Session Variable in javascript
Hi Starr,
Thank u for ur nice reply.
I have done the first part what u have mentioned by using
"document.cookie".
I am new to XMLHttpRequest(XHR) will you please guide me a little more
on this with example.
I have following code written in javascript
var selObj = document.getElementById(''zone'');
var i;
var count = 0;
for (i=0; i<selObj.options.length; i++) {
if (selObj.options[i].selected) {
selectedArray[count] = selObj.options[i].value;
count++;
}
}
document.cookie="zone_ids=" + selectedArray.toString();
var r = document.cookie;
I want to pass this cookie value to my account controller method
say "add"
And after passing how can I access it in the controller?
I am googleing for the same but don''t find good materials.
Please help me out
Thanks and Regards,
Shripad
On Mar 19, 6:49 pm, Starr Horne
<st...-wG8FsLYNbnsysxA8WJXlww@public.gmane.org>
wrote:> > Can any one tell me, how can I Pass a javascript variable value to a
> > ROR session variale in javascript.
>
> You can either:
>
> 1) Set a cookie in JS and have your rails app read the cookie. If
you''re using not using DB-backed sessions, this may be sufficient. You
may not need to use rails'' actual sessions mechanism.
>
> 2) Have your JS do an XHR request to a special controller action which will
save your data to the session.
>
> --
> Starr Horne
> Check out my Helpdesk RailsKit:http://railskits.com/helpdesk/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---