populating variable from jquery to php using datatables 1.10.0

populating variable from jquery to php using datatables 1.10.0

naveen3562003naveen3562003 Posts: 8Questions: 3Answers: 0
edited November 2014 in Free community support

friends,

I am hoping that I will get some solution on my problem.

I just trying to passing a variable between Jquery to PHP so that I can concat mysql for getting other related values and project in in the form of HTML.

'

/* Formatting function for row details - modify as you need */ $(document).ready(function() { var table = $('#example').DataTable( { "sAjaxSource": "/la/json/data.php", "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]], "sPaginationType" : "full_numbers", "paging": true, "bProcessing": true, "iDisplayLength":50, "iDisplayStart":0, "scrollY": "auto", "scrollX": true, "scrollCollapse": true, "fnServerData": function( aUrl, aaData, fnCallback ) { $.ajax( { "url": aUrl, "data": aaData, "success": fnCallback, "dataType": "json", "cache": false, }); }, "aaSorting": [[ 0, "desc" ]], "tableTools": { "sSwfPath": "/la/swf/copy_csv_xls_pdf.swf" }, "bFilter": true, "sDom": 'f<"top"Cl>rt<"clear"><"bottom"iTp>', "colVis": {activate: "mouseover"}, "bPaginate": true, "bLengthChange": true, "bAutoWidth": true, }); /*/ Function to perform button function $('#example tbody').on( 'click', 'button', function () { var data = $('td', this).eq(0).text(); alert( 'You clicked on '+data+'\'s row' ); });*/ // Function to perform button function $('#example tbody').on('click','tr', function () { var oTable = $('#example').dataTable(); //var data1 = $('td', this).eq(1).text(); var oData = oTable.fnGetData($('#example tbody tr:eq(3)')[0]); $.ajax({ url: 'main.php', type: 'POST', data: oData }); //alert( 'You clicked on '+oData+'\'s row' ); //var node = $('td', this).eq(3).text(); $( "#accordion" ).accordion({ heightStyle: "content", active: 0, collapsible: true }); $( "#accordion-resizer" ).resizable({ resize: function() { $( "#accordion" ).accordion( "refresh"); } }); var $dialog = $("#server") .dialog({ //title: data1+'*****'+node, autoOpen: false, resizable: true, height: 627, hide: "puff", width: 700, show: { effect: 'slide'}, modal: true, draggable: true, buttons: { 'Close': function() { $dialog.dialog('close'); } } }); //document.getElementById('accordion-resizer').innerHTML = '' +'
Full Name:' + oData[1]+ '
'; $dialog.dialog('open'); }); });

'

>
My php is

'<?php if(isset($_POST['oData'])){ >echo $dataTable = $_POST["dataTable"];} ?>'

Answers

  • captain_theocaptain_theo Posts: 3Questions: 1Answers: 0
    edited December 2014

    I had the same or similar problem with you. I managed however to find the solution by myself as there were practically no replies to my question.
    Trying to pass variable from js to php never worked for me.
    But when I used this variable in the server-side script to do the other query (in the same file) worked perfectly!
    To cut the long story short, you may want to have a look at stackoverflow where I posted my question and then my answer: http://stackoverflow.com/questions/26950516/ajax-response-render-to-datatables-column ...Hope this comes as close as possible to what you were looking for! (I use datatables 1.10 with server side script.)

This discussion has been closed.