session variable is empty after get request in rails3

26 views
Skip to first unread message

amvis

unread,
Apr 22, 2012, 5:33:37 AM4/22/12
to rubyonra...@googlegroups.com
i have one page, b.html.erb, when i load  that page,that have one text filed and button. when i click on that button, button class = sub123  (Here an ajax Get request will happen), after processing another div(that button class =addsubmit ) will shows in same page.

ajax


$(".sub123").click(function() {
var mnum = $("#mnum").val();

var dataString = 'value='+ mnum;

if(mnum=='')
{
$('.error').fadeIn(300).show();
$('.error').fadeOut(3000);

}
else
{
  
$.ajax({
type: "GET",
data: dataString ,
success: function(){
$('#billerTerminal').fadeIn(200).show();
$('.checked3').fadeIn(200).show();
$('.error').fadeOut(200).hide();
$('.adddtl').hide();
}
});
}
return false;
});


$(".addsubmit").click(function() {
var bnum = $("#bnum").val();
var bamount = $("#bamount").val();
var dataString = 'bnumber='+ bnum + '&bamount=' + bamount;

if(bnum=='' || bamount=='' )
{
$('.adderror').fadeIn(300).show();
$('.adderror').fadeOut(3000);


}
else
{
  
$.ajax({
type: "POST",
data: dataString,
success: function(){

$('.adderror').fadeOut(200).hide();
$('.addsuccess').fadeIn(200).show();
$(".addsuccess").fadeOut(3000);
$('.adddtl').fadeIn(200).show();
}
});
}
return false;
});

class BpagesController < ApplicationController
    
  def show
  //GET request...
    @user_name = session[:user_name]
    @password = session[:password]
    //Here i can see these two values
  end
 
  def addt
    /POST
    @user_name1 = session[:user_name]
    //HERE this SESSION is EMPTY............what am i wrong?
  end
  
  
end
These two call happens in one page, why i didn't get that session variable in another POST request.......?


Thank you
vishnu


amvis

unread,
Apr 22, 2012, 6:20:17 AM4/22/12
to rubyonra...@googlegroups.com
I have solved my issues, with add gem 'jquery-rails', '>= 1.0.12' in Gem file.


Thank you
vishnu
Reply all
Reply to author
Forward
0 new messages