سؤال

my script

<script type="text/javascript">
$(document).ready(function() {
    $('.all').dataTable( {
        "bInfo": false,
        "bProcessing": true,
        "sPaginationType": "full_numbers",
        "aLengthMenu": [[25, 50, 75, 100], [25, 50, 75, 100]],
        "iDisplayLength": 25,
        "bServerSide": true,
        "sAjaxSource": "Get_Pmob_tra",
        "bPaginate": true,
        "oLanguage": {
            "sProcessing": "<img src='gfx/ajax-loader.gif'>"
        }
    } );
} );

</script>

and I am using datatable class to process the files

I need to get a new value from html to the PHP with an ajax call

How can I do this?

هل كانت مفيدة؟

المحلول

Use fnServerParams, like this:

...
"sAjaxSource": "Get_Pmob_tra",
"fnServerParams": function (aoData) {
            aoData.push({ "name": "myval", "value": $('#myselect :selected').val() });
},
"bPaginate": true,
...

This example gets the selected value of a selectlist with the id='myselect', and passes it as a parameter called 'myval'. In your server-side Get_Pmob_tra php code, get the parameter from the request:

Request.QueryString["myval"]

sorry that's not specifically PHP code, but you get the idea.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top