2

I have this code to draw datatables, so I try to get data from server in JSON format but I need to send data: ajdi variable... My code:

function drawMeh() {

                $('#Meh').dataTable({ 
                    "ajax": "track_meh.php",
                    paging: false,
                    //"dom":' <"search"f><"top"l>rt<"bottom"ip><"clear">',
                    // end ,
                    "columns": [{
                            "data": "ID"}, {
                            "data": "datum"}, {
                            "data": "masina"},{
                            "data": "radnih_sati"},{
                            "data": "kolicina"},{
                            "data": "cena"},{
                            "data": "ukupno"},{
                            "data": "akcija"
                        }
                    ],

                    "columnDefs": [
                            {
                        "targets": 7,
                        "data": "akcija",
                        "render": function(data, type, full, meta) {
                            // return data; 
                            return '<div style="float:right;"><i  class="fa fa-close"></i></div>';
                        }
                            },

                            {
                        "targets": [0],
                        "visible":false
                            }

    ]
                });

            };

How I can send data: ajdi to server to get right JSON data from track_meh.php ?

2 Answers 2

2

Here is from datatable 1.10:

 "ajax" : {
                "url" :  "track_meh.php",
                "type" : "POST",
                "data" : ajdi
            },

Here is from the legacy:

$(document).ready( function() {
  $('#example').dataTable( {
    "bProcessing": true,
    "bServerSide": true,
    "sAjaxSource": " track_meh.php",
    "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
      oSettings.jqXHR = $.ajax( {
        "dataType": 'json',
        "type": "POST",
        "url": sSource,
        "data": ajdi,
        "success": fnCallback
      } );
    }
  } );
} );
Sign up to request clarification or add additional context in comments.

1 Comment

Perfect! Worked like charm.
0

something like this, http://prototypejs.org/learn/introduction-to-ajax

new Ajax.Request('/some_url', {
  method: 'get',
  parameters: {company: 'example', limit: 12}
});

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.