Hello,
In my case DataTables to connect to my database to show my subscribers.
But for every subscriber I absolutely need to display information from an API.
Here is my php script to retrieve information
And here is my script for DataTables.
How to put in $('td:eq(0)', nRow).html( 'Value_of_the_API' ) ;, the result returned by the API.
Thank you for your help and happy new year.
In my case DataTables to connect to my database to show my subscribers.
But for every subscriber I absolutely need to display information from an API.
Here is my php script to retrieve information
<?php $statut = Newsletter::MJStatutMailAbo( aData['mail'] ); $satutAbo= ($statut->spam ? '<img src="/back_office/images/template/icon16-spam.png" border="0" class="icon16 infobulle" title="SPAM">' : ''); $satutAbo.= ($statut->bounce ? '<img src="/back_office/images/template/icon16-bounce.png" border="0" class="icon16 infobulle" title="ERREUR">' : ''); $satutAbo.= ($statut->blocked ? '<img src="/back_office/images/template/icon16-blocked.png" border="0" class="icon16 infobulle" title="BLOQUÉ">' : ''); ?>
And here is my script for DataTables.
$(document).ready(function() { oTable = $('#tbl_result').dataTable( { "sDom": '<"top"fl>rt<"bottom"pi>' , "sPaginationType": "full_numbers", "bAutoWidth" : false, "bProcessing": true, "bSortClasses" : false, "iDisplayLength": 10, "bStateSave" : false, "bServerSide": true, "oLanguage": { "sUrl": "/includes/js/DataTables.fr.js" }, "sAjaxSource": "scripts/objects.php", "fnRowCallback": function( nRow, aData, iDataIndex ) { $('td:eq(0)', nRow).html( 'Value_of_the_API' ) ; $('td:eq(2)', nRow).html( DateFr(aData['date']) ) ; $('td:eq(3)', nRow).html( ( aData['etat'] == '0' ? 'Inscrit' : 'En attente') ) ; $('td:eq(4)', nRow).html( '<a user="' + aData['mail'] + '" class="delete" href="?id_abonne='+ aData['mail'] +'"><img border="0" class="icon16 infobulle" src="/back_office/images/template/icon16-delete.png"></a>'); }, "aoColumns" : [ { "mData": "mail" }, { "mData": "mail" }, { "mData": "date" }, { "mData": "etat", "bSortable": false}, { "mData": "cle", "bSortable": false} ], "aaSorting" : [ [0,'desc'] ] } ); } );
How to put in $('td:eq(0)', nRow).html( 'Value_of_the_API' ) ;, the result returned by the API.
Thank you for your help and happy new year.