Skip to content

Instantly share code, notes, and snippets.

@OliPelz
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OliPelz/7d46ac01e888b6fd2829 to your computer and use it in GitHub Desktop.
Save OliPelz/7d46ac01e888b6fd2829 to your computer and use it in GitHub Desktop.
server-side datatable GET request
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=us-ascii">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="stylesheet" href="//cdn.datatables.net/1.10.1/css/jquery.dataTables.css" />
</head>
<body>
<table id="example" class="display" width="100%" cellspacing="0">
<thead>
<tr>
<th>Phenotype Name</th>
<th>Organism</th>
</tr>
</thead>
<tfoot>
<tr>
<th>phenoName</th>
<th>organismName</th>
</tr>
</tfoot>
</table>
<script data-require="jquery@1.10.1" data-semver="1.10.1" src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="//cdn.datatables.net/1.10.1/js/jquery.dataTables.js"></script>
<script type="text/javascript" data-require="angular.js@1.2.15" data-semver="1.2.15" src="http://code.angularjs.org/1.2.15/angular.js"></script>
<script type="text/javascript" src="https://rawgithub.com/l-lin/angular-datatables/dev/dist/angular-datatables.min.js"></script>
<script>
$(document).ready(function() {
$('#example').dataTable( {
"bServerSide": true,
"fnServerData": function (sSource, aoData, fnCallback) {
var myData = JSON.stringify(aoData);
$.ajax({
"dataType": 'json',
"contentType" : "application/json;charset=utf-8",
"type": "GET",
"url": "http://localhost:3000/ajax/phenotypes/withOrg/like/datatables/",
"data": myData,
"success": fnCallback,
"error": function () {
alert('have some problem');
}
});
}
} );
} );
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment