locked
get /set session value in jquery RRS feed

  • Question

  • User639567535 posted

    I tried to get session value like this

    success: function (result) {
    debugger;
    var m = JSON.parse(result.d).response;
    console.log(JSON.parse(result.d).response);
    alert("!2)");
    debugger;
    
    var master = $('#master_table').DataTable({
    "dom": 'Blfrtip',
    "columns": [
    
    {
    "title":" Type",
    "data":" Type"
    }, {
    "title": "Frequency",
    "title": "Frequency",
    },
    
    ]
    
    });
    for(var i=0;i<m.length;i++)
    {
    if (m[i] !== null)
    {
    master.row.add({
    "Type": m[i][0],
    " Frequency": m[i][1]
    
    })
    }
    } 
    $.session.set("Type", m[i][0]);
    $.session.set("Frequency", m[i][1]);
    
    



    and get value

    <script type="text/javascript">
    alert("4aaaa");
    $(function () {
    debugger;
    $('#master_table').on('click', 'tr', function () {
    debugger;
    var row = $(this); 
    $.session.get("Type");
    var Type = $("#master_table tr.selected").find('td:eq(0)').html();
    var Frequency = $("#master_table tr.selected").find('td:eq(1)').html();
    var s = {};
    
    s. Type = Type;
    s.Frequency = Frequency;
    
    alert(JSON.stringify(s));
    
    });
    
    



    but i did not get value of type and also there not any error on console.. how i do this .. i tried to set session in one script and get value in another script but get value is not display like if type is abc then in get value must be abc..

    Wednesday, October 26, 2016 8:42 AM

All replies

  • User753101303 posted

    Hi,

    Beyond no error what happens? Still use the Network tab to check your Ajax request. You have an error function to show something if the Ajax request fails. My understanding is that you are trying to change/retrieve session values using Ajax calls. It seems you have breakpoint also but you don't tell if they are hit or whatever etc...

    The big picture might help. You have really to update those values on the server side each time to just get on the client side value a value you previously posted from the client side etc... ?

    Wednesday, October 26, 2016 8:50 AM
  • User639567535 posted

    Hi,

    Beyond no error what happens? Still use the Network tab to check your Ajax request. You have an error function to show something if the Ajax request fails. My understanding is that you are trying to change/retrieve session values using Ajax calls. It seems you have breakpoint also but you don't tell if they are hit or whatever etc...

    The big picture might help. You have really to update those values on the server side each time to just get on the client side value a value you previously posted from the client side etc... ?

    this shows 

    $.session.get("Type");

    not 

    $.session.get("abc");

    Wednesday, October 26, 2016 9:05 AM
  • User753101303 posted

    And ?

    For now it seems hardcoded in your script? Or do you mean that this script is rendered from the server side based on some variable and that you would expect to really see $.session.get("abc") on the client side ??? Is this related to the Ajax call you shown. Or is the question about how to replace "Type" with some parameter so that the some code could run with other session variable names ?

    Also :
    - isn't $.session.get("Type"); supposed to return value? If yes you are doing nothing at all with the returned value
    - it seems you are using a session plugin. Do you have a link so that we can understand what this plugin does?
    - is the Ajax success code you shown relevant? (is it related to this plugin ?)
    - make sure to show only relevant code

    For now I just see some code but don't get what you are really trying to do (reading/setting server side session variable using Ajax ?) and what is the exact problem in doing what you are trying...

    Edit: To start with could you confirm first that what you are trying to do is to read and write server side session variables from your page? (or even possibly the bigger picture, for now it seems you are trying to select data from a client side row and post them to the server ??? ).

    Wednesday, October 26, 2016 3:29 PM