subbarao
2011-Oct-20 06:19 UTC
Jquery AJAX not working with session It is not taking old session.
In my rails application when I trigger a Ajax request with my
javascript in below way
$j.ajax({
type: "POST",
url: "https://fbapp.pinkienow.com/requests",
data: "requstids="+response.request_ids
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});
The request is firing correctly but it is not taking my old session
values of user
It is showing error that your session variable is not available in my
log
any idea why it is not taking previous session ?
and how to fix that ?
Thank you in advance.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
subbarao
2011-Oct-20 06:59 UTC
Re: Jquery AJAX not working with session It is not taking old session.
I got solution
we need to add below code in your header javascript, which tells use
browser cookie in server externally
###############################################
$(document).ajaxSend(function(e, xhr, options) {
var token =
$("meta[name=''csrf-token'']").attr("content");
xhr.setRequestHeader("X-CSRF-Token", token);
});
################################################
normally by default xhr willnot sent sessionid to server .
On Oct 20, 11:19 am, subbarao
<subbarao....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> In my rails application when I trigger a Ajax request with my
> javascript in below way
>
> $j.ajax({
> type: "POST",
> url: "https://fbapp.pinkienow.com/requests",
> data: "requstids="+response.request_ids}).done(function( msg )
{
>
> alert( "Data Saved: " + msg );
>
> });
>
> The request is firing correctly but it is not taking my old session
> values of user
>
> It is showing error that your session variable is not available in my
> log
>
> any idea why it is not taking previous session ?
> and how to fix that ?
>
> Thank you in advance.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.