how can I pass parameters through DataTable().ajax.reload() using datatable conect

how can I pass parameters through DataTable().ajax.reload() using datatable conect

SandeepMuralaSandeepMurala Posts: 48Questions: 13Answers: 0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem:

This question has an accepted answers - jump to answer

Answers

  • SandeepMuralaSandeepMurala Posts: 48Questions: 13Answers: 0

    Hi ,
    my code is like shown below,

     $('#quess_table_server').DataTable( {   
            "processing": true,
            "serverSide": true,
            "ajax": "server_selectUser.php?loginUser="+loginUser+"&SelcetedUser="+SelcetedUserArray1+"&start_dt="+start_dt+"&end_dt="+end_dt,
        } );
    

    this code will run when i open the test.php at that time I am passing only selectedUser remaining(SelcetedUserArray1,start_dt and end_dt) are empty .

    I have one button called GO i have written below code

    $('#Go_Id').click((funtion(){
                   SelcetedUser = document.getElementById("selectedUser").value;       
            start_dt = document.getElementById("start_date").value;
            end_dt = document.getElementById("end_date").value;
                 $('#quess_table_server').DataTable().ajax.reload();
    
    }
    

    when i click that Go button i am reloading the datatable ,now in this case iam passing the SelcetedUserArray1,start_dt and end_dt .
    Here i am getting the problem bez this datatable() is out of the event so I am unble to pass the "SelcetedUserArray1,start_dt and end_dt ",

    Is there any way to pass this paramenter to that datatable .

    plz help on it .

    Thanks
    Sandeep

  • kthorngrenkthorngren Posts: 21,182Questions: 26Answers: 4,925

    Use the ajax.data option as a function to retrieve the data you want to pass as parameters in the ajax request.

    Kevin

  • SandeepMuralaSandeepMurala Posts: 48Questions: 13Answers: 0

    Hi @kthorngren thank you so much for your reponse ,
    I have went through your suggestion ,sorry I did not get you, could you plz explain littile bit more ,in my case how can I procced .I am new to this datatable concept .

    Thanks
    Sandeep

  • kthorngrenkthorngren Posts: 21,182Questions: 26Answers: 4,925

    Here is an example you can look at.

    Kevin

  • SandeepMuralaSandeepMurala Posts: 48Questions: 13Answers: 0

    @kthorngren ,I went through your suggestion,

    In my case I am reloading the datatable when I click the "Go" button by using $('#quess_table_server').DataTable().ajax.reload();

    i am reloading this below code

    ```
    $('#quess_table_server').DataTable( {
    "processing": true,
    "serverSide": true,
    "ajax": "server_selectUser.php?loginUser="+loginUser+"&SelcetedUser="+SelcetedUserArray1+"&start_dt="+start_dt+"&end_dt="+end_dt,
    } );


    here I have to pass this variable ``` SelcetedUserArray1,start_dt and end_dt ```into above code when i reload the datatable . you can see the ````click event``` below when I click on ```Go``` button

    $('#Go_Id').click((funtion(){
    SelcetedUser = document.getElementById("selectedUser").value;
    start_dt = document.getElementById("start_date").value;
    end_dt = document.getElementById("end_date").value;
    $('#quess_table_server').DataTable().ajax.reload();

    }
    ```

    i am sorry repeat this question ,but i am new to this concept ,i have been trying to undertand the concept plz help me on it and save my day.

    Note : problem is when i click the Go button i am able to get all this values```` SelcetedUserArray1,start_dt and end_dt ``` in that click event then next line i am reloading the datatable,that datatable out of the event ,so i am unable to sent this variable to datatable({...}) file(server_selectUser.php), I tried making globla variable also but it is showing undified only .

    How can i solve this problem .

    thanks
    sandeep

  • SandeepMuralaSandeepMurala Posts: 48Questions: 13Answers: 0

    @kthorngren ,
    thanks for you valuable time ,

    I went through your suggestion ,I am new to this datatable conect so i have been trying to undertand this concept ,

    In may case I have button called GO when I click this button this below event will trigger

    $('#Go_Id').click((funtion(){
                   SelcetedUser = document.getElementById("selectedUser").value;      
            start_dt = document.getElementById("start_date").value;
            end_dt = document.getElementById("end_date").value;
                 $('#quess_table_server').DataTable().ajax.reload();
     
    }
    
    

    in above code you can see I am getting all the values like

    SelcetedUser
    start_dt 
    end_dt
    

    then last line i am reloading the datatable which is out of the click event ,that code you can see in below

    $('#quess_table_server').DataTable( {  
           "processing": true,
           "serverSide": true,
           "ajax": "server_selectUser.php?loginUser="+loginUser+"&SelcetedUser="+SelcetedUserArray1+"&start_dt="+start_dt+"&end_dt="+end_dt,
       } );
    

    so in this I am unable to pass those variable bez this datatable is out of the event ,

    I trid with GLOBAL variable then It was showing 'undefind'.

    So how can i pass this click event variable into datatable ,

    Plz help on it and save my day .it so appreciate.

    sorry to explain once again .

    Thanks
    Sandeep

  • kthorngrenkthorngren Posts: 21,182Questions: 26Answers: 4,925
    Answer ✓

    The ajax.data docs have some examples. Take a look at the second example which is using a function to get the input values. Sounds like that is what you want to do.

    Kevin

This discussion has been closed.