1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

sessions across jquery ajax call

Discussion in 'jQuery' started by StuartC, Dec 2, 2010.

  1. #1
    Hey Guys,

    Kind of a strange problem, hopefully someone can help me out.

    I want to set a session in my rails controller which I hit via jquery ajax get.

    $.get('/leads/check', function(data) {console.log(data);});

    which hits the controller action

    def check
    session[:tester] = "test"
    end

    The session doesnt seem to be set across the ajax call and the js console gave back
    "Failed to load resource: the server responded with a status of 500 (Internal Server Error)"

    Checking the rails logs also verifys that the controller check action is hit..

    Anyone have an ideas on this?

    Cheers,

    Stuart
     
    StuartC, Dec 2, 2010 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    Alert data, it should show you the response of the controller and any errors if any.
     
    ThePHPMaster, Dec 5, 2010 IP
  3. hardik_dan

    hardik_dan Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i believe it could be because of two reasons.
    1) session needs to activated at the start of controller.
    2) and if your server space is full then session files became read-only and gives you strange 500 errors.
     
    hardik_dan, Dec 9, 2010 IP
  4. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Just start the session at the beginning of each file (in php session_start() ) , even in your ajax call php file and everything will be ok.
     
    tvoodoo, Dec 9, 2010 IP
  5. mohsince

    mohsince Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks dude .. nice info.
     
    mohsince, Dec 17, 2010 IP